akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

c = [list(map(int, readline().split())) for _ in range(3)]

ans = 'Yes'
if not c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]:
    ans = 'No'
if not c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]:
    ans = 'No'
if not c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2]:
    ans = 'No'
if not c[2][0] - c[1][0] == c[2][1] - c[1][1] == c[2][2] - c[1][2]:
    ans = 'No'
print(ans)


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define inf 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

int gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};

typedef pair<int, int> pi;
typedef long long i64;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

int w, h;

void dfs(int y, int x, auto &grid, auto &visited) {
  if(!grid[y][x] || visited[y][x]) return;

  visited[y][x] = true;
  rep(i, 0, 8) {
    dfs(y + dy[i], x + dx[i], grid, visited);
  }
}

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

  while(cin >> w >> h, w && h) {
    vvt<bool> grid(h + 2, vt<bool>(w + 2, false));
    vvt<bool> visited(h + 2, vt<bool>(w + 2, false));

    rep(i, 1, h + 1) {
      rep(j, 1, w + 1) {
        int c;
        cin >> c;
        grid[i][j] = !!c;
      }
    }

    int cou = 0;
    rep(i, 1, h + 1) {
      rep(j, 1, w + 1) {
        if(!grid[i][j] || visited[i][j]) continue;

        cou++;
        dfs(i, j, grid, visited);
      }
    }
    cout << cou << endl;
  }
}



Measured memory_bytes: 3208
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
  int n;
  double count=0.0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
  if(i%2==1){
    count++;
  }
    
  }
      printf("%f",count/n);
}


Measured memory_bytes: 128
input = STDIN.readlines.map{|line|line.strip.split()}
n = input[0][0].to_i

max = 0
sum = 0
n.times do |num|
    p = input[num + 1][0].to_i
    if p > max then
        max = p
    end
    sum += p
end
puts(sum - max / 2)


Measured memory_bytes: 1788
N = int(input())
A = [int(i) for i in input().split()]

yama1 = A[0]
for i in range(1,N):
  if int(i) % 2 == 1:
    yama1 -= A[i]
  else:
    yama1 += A[i]
yamas = [yama1]

for i in range(N-1):
  yamas.append(A[i]*2-yamas[i])

print(*yamas, sep=' ')

Measured memory_bytes: 14024
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

string s;

int main(){
    cin >> s;
    bool flag = true;
    rep(i,s.size()){
        // cout << flag << " " << i  << endl;
        if(i%2==0 && s[i] == 'L') flag = false;
        if(i%2 && s[i] == 'R') flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;


return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/perl

use strict;
use warnings;
use 5.010;

use Data::Dumper;

my @INPUT;
while (<>) {
    chomp;
    push @INPUT, $_;
}

my $N = shift @INPUT;
my @p = @INPUT;

my $max = 0;
my $sum = 0;
for my $p (@p) {
    $sum += $p;
    if ($max < $p) {
        $max = $p;
    }
}

my $ans = $sum - $max/2;
say $ans;


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   string s[3];
           rep(i,0,3)cin>>s[i];
           rep(i,0,3){
            cout<<char(s[i][0]+'A'-'a'); 
           }
           cout<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;

  cin >> N ;

  vector<char> S(N);

  for(int i=0;i<N;i++) cin >> S.at(i);

  bool ans=false;

  for(int i=0;i<N;i++){
    if(S.at(i)=='Y') ans=true;
  }

  if(ans) cout << "Four" << endl;

  else cout << "Three" << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define int long long 
using namespace std;

int32_t main(){

    int n,k;  cin >> n >> k;
    vector<pair<int,int>> a(n);
    for(int x=0;x<n;x++){
        pair<int,int> p;
        cin >> p.first >> p.second;
        a[x] = p;
    }

    sort(all(a));

    for(int x=0;x<n;x++){
        k -= (a[x].second);
        if(k <= 0){
            cout << a[x].first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=1,c=0;
	string s;
	cin >> n >> k;

	// if(k==1){
	// 	cout << "0" << endl;
	// 	return 0;
	// }

	// for(int i=1;i<20;i++){
	// 	ans = n*i;
	// 	if(ans>=k){
	// 		c=i;
	// 		break;
	// 	}
	// }

	while(ans<k){
		ans+=n;
		ans-=1;
		c++;
	}

	cout << c << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        if((b-a)%2 == 0){
            System.out.println("Alice");
        }else{
            System.out.println("Borys");
        }
        
    }
}

Measured memory_bytes: 23764
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
int main()
{
	int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d %d %d",&t,&x,&y);
        if((x+y)%2+t%2==1||x+y>t)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
	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();
		String x="0";
		Card[] C = new Card[N];
		Card[] CB = new Card[N];
		Card[] CS = new Card[N];
		for(int i=0;i<N;i++){
			String str = sc.next();
			int a=str.charAt(1)-x.charAt(0);
			C[i]=new Card(str.charAt(0),a);
			CB[i]=C[i];
			CS[i]=C[i];
		}
		
		BubbleSort(CB);
		SelectionSort(CS);
		for(int i=0;i<N;i++){
			if(i==N-1){
				CB[i].print();
				System.out.println();
			}else{
				CB[i].print();
				System.out.print(" ");
			}
		}
		if(Scheck(C,CB)){
			System.out.println("Stable");
		}else{
			System.out.println("Not stable");
		}
		for(int i=0;i<N;i++){
			if(i==N-1){
				CS[i].print();
				System.out.println();
			}else{
				CS[i].print();
				System.out.print(" ");
			}
		}
		if(Scheck(C,CS)){
			System.out.println("Stable");
		}else{
			System.out.println("Not stable");
		}

	}
	
	static void BubbleSort(Card[] C){
		for(int i=0;i<C.length;i++){
			for(int j=C.length-1;j>i;j--){
				if(C[j].value<C[j-1].value){
					Card t=C[j];
					C[j]=C[j-1];
					C[j-1]=t;
				}
			}
		}
	}
	
	static void SelectionSort(Card[] C){
		for(int i=0;i<C.length;i++){
			int mini=i;
			for(int j=i;j<C.length;j++){
				if(C[j].value<C[mini].value){
					mini=j;
				}
			}
			if(i!=mini){
				Card t=C[i];
				C[i]=C[mini];
				C[mini]=t;
			}
		}
	}

	static boolean Scheck(Card[] A,Card[] B){
		boolean check=true;
		for(int i=1;i<B.length;i++){
			if(B[i-1].value==B[i].value){
				int f=0;
				int e=0;
				for(int j=0;j<A.length;j++){					
					if(B[i-1]==A[j]){
						f=j;
					}
					if(B[i]==A[j]){
						e=j;
					}
				}
				if(e<f){
					check=false;
					break;
				}
			}
		}
		return check;
	}
}

class Card{
	char suit;
	int value;
	Card(char a,int b){
		suit=a;
		value=b;
	}
	public void print(){
		System.out.printf("%c%d",suit,value);
	}
}

Measured memory_bytes: 26436
using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
           
            decimal[] nm = Array.ConvertAll(System.Console.ReadLine().Split(' '), decimal.Parse);
            long n = (long)nm[0];
            int m = (int)(nm[1] * 100);

            System.Console.WriteLine(n*m/100);

        }
    }
}


Measured memory_bytes: 27488
N,W=map(int,input().split())
dp = [0]*(W + 1)

def solve_knapsack(capacity):
    # basic checks
 
    
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit

    for i in range(0, N):
        weights,profits = map(int,input().split())
        for c in range(capacity, weights-1, -1):
            tmp = profits + dp[c - weights]
            if tmp > dp[c]: dp[c] = tmp
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
 
    res = solve_knapsack(W)
 
    print(res)
if __name__ == "__main__":
	main()

Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N; cin>>N;
  vi A(N),B(N);
  int ans=0;
  rep(i,0,N) cin>>A[i]>>B[i];
  vector<pii> C(N);
  rep(i,0,N) cin>>C[i].first>>C[i].second;
  sort(ALL(C));
  vector<bool> F(N,1);
  rep(i,0,N){
    int memo=-1,Max=-1;
    rep(j,0,N){
      if(A[j]<C[i].first&&F[j]&&C[i].second>B[j]){
        if(Max<B[j]){
          memo=j;
          Max=B[j];
          }
        }
      }
    if(memo!=-1){
      ans++;
      F[memo]=0;
      }
    }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<cmath>
#include<unordered_set>
#define int long long
#define P pair<int,int>
using namespace std;

int p[100000];//各頂点の親
vector<int>r[100000];
int D[100000];//各頂点の深さ
P c[100000];
int ans[100000];
vector<int>MIN[100000], MAX[100000];
void DFS(int a) {
	for (int b : r[a]) {
		if (p[b] == -1) {
			p[b] = a;
			D[b] = D[a] + 1;
			DFS(b);
		}
	}
}
signed main() {
	int n; cin >> n;
	memset(p, -1, sizeof(p));
	memset(ans, 0x3f, sizeof(ans));
	p[0] = 0;
	for (int i = 1; i < n; i++) {
		int a, b; cin >> a >> b; a--; b--;
		r[a].push_back(b);
		r[b].push_back(a);
	}
	DFS(0);
	for (int i = 0; i < n; i++) {
		c[i] = { D[i],i };
	}
	int k; cin >> k;
	for (int i = 0; i < k; i++) {
		int a, b; cin >> a >> b; a--;
		ans[a] = b;
	}
	sort(c, c + n, greater<P>());
	for (int i = 0; i < n; i++) {
		int sum = 0;
		int MIN = -(1 << 29), MAX = 1 << 29;//OKな最小値、最大値
		set<int>S;
		for (int j : ::MIN[c[i].second]) {
			MIN = max(MIN, j);
			S.insert(j & 1);
			sum++;
		}
		for (int j : ::MAX[c[i].second]) {
			MAX = min(MAX, j);
		}
		if (ans[c[i].second] < INT_MAX) {
			sum++;
			S.insert(ans[c[i].second] & 1);
			if (S.size() == 2) {
				puts("No");
				return 0;
			}
			if (sum>1) {
				if (MAX<ans[c[i].second] || MIN>ans[c[i].second]) {
					puts("No");
					return 0;
				}
			}
			MIN = MAX = ans[c[i].second];
		}
		if (sum) {
			if (MIN > MAX) { puts("No"); return 0; }
			::MIN[p[c[i].second]].push_back(MIN-1);
			::MAX[p[c[i].second]].push_back(MAX+1);
		}
		if (c[i].second == 0) {
			ans[0] = MIN;
		}
	}
	for (int i = n - 1; i >= 0;i--) {
		int MIN = -(1 << 29), MAX = 1 << 29;//OKな最小値、最大値
		for (int j : ::MIN[c[i].second]) {
			MIN = max(MIN, j);
		}
		for (int j : ::MAX[c[i].second]) {
			MAX = min(MAX, j);
		}
		if (ans[c[i].second] < INT_MAX) {
			MIN = MAX = ans[c[i].second];
		}
		for (int j : r[c[i].second]) {
			::MIN[j].push_back(MAX - 1);
			::MAX[j].push_back(MIN + 1);
		}
		ans[c[i].second] = MIN;
	}
	puts("Yes");
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 27520
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
 
using namespace std;

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

    int N;

    cin >> N;

    vector<int> h(N);

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

    int c = 0;
    int p = 0;

    while(p < N) {
        if(h[p] > 0) {
            c++;
            int s = p;
            while(h[s] > 0 && s < N) {
                h[s]--;
                s++;
            }
        } else {
            p++;
        }
    }

    cout << c << endl;
}


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

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

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

  for (int i = 0; i < N - 1; i++) {
    if (vec[i] == vec[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int kane;
  int happy=0;
  
  scanf("%d",&kane);
  
  while(kane>=500){
    kane=kane-500;
    happy=happy+1000;
  }
  
  while(kane>=5){
    kane=kane-5;
    happy=happy+5;
  }
  
  printf("%d",happy);
  
  return 0;
}

Measured memory_bytes: 1732
w = input()
alp = 'abcdefghijklmnopqrstuvwxyz'
c = []
for i in range(26):
    a = w.count(alp[i])
    c.append(a)
d = 0
for i in range(26):
    if c[i] % 2 == 0:
        d = 1
    else:
        d = 0
        break
if d == 0:
    print('No')
else:
    print('Yes')

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int k;
    cin >> k;
    if (k % 2 == 1)
        OP((k / 2 + 1) * (k / 2));
    else
        OP((k / 2) * (k / 2));
        
    return 0;
}

Measured memory_bytes: 256
ninnzuu = (int)(input())
joushi = list(map(int, input().split(" ")))
buka = [0 for i in range(ninnzuu)]
for i in range(ninnzuu - 1):
    buka[joushi[i]] += 1
for i in range(1, ninnzuu):
  print(buka[i])
print(0)

Measured memory_bytes: 32172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b; cin >>a>>b;
  long long count=1;
  long long kotae=a;
  while(kotae<=b){
    kotae*=2;
    //cout<<kotae<<endl;
    if(kotae>b)break;
    count++;
  }
  cout <<count<<endl;
}

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

int main() {
	int N;
	cin>>N;
	vector <string> S(N,"");
	vector  <int>   T(N,0);   
	for(int i=0; i<N; i++){
		string s;
		int t;
      	cin>>s>>t;
		S[i]=s;
		T[i]=t;
	}
	string X;
	cin>>X;
	int sum=0,flag=-1;
	for(int i=0; i<N; i++){
		if(flag==1){
			sum+=T[i];
		}
		if(X==S[i]) flag=1;
	}
	cout<<sum<<endl;
}
		
		
		
		
		
		
		
		
		
		
		
	


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, k, cnt;
string s;


int main() {
	cin >> n >> k;
	cin >> s;
	REP(i, n - 1) {
		if (s[i] != s[i + 1]) {
			cnt++;
		}
	}
	cnt /= 2;
	ll ans = 0;
	REP(i, n - 1) {
		if (s[i] == s[i + 1])ans++;
	}
	REP(i, k) {
		if (cnt > 0) {
			ans += 2;
		}
		else ans++;
	}
	cout << min(ans, n - 1) << endl;
}
	


Measured memory_bytes: 512
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, X] = input[0].map(Number);

  return A <= X && A + B >= X ? "YES" : "NO";
};

console.log(main(read()));


Measured memory_bytes: 29576
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
double f[1005][1005],dis[1005],a[1005][3];
bool b[1005];
int main()
{
    int i,j,k,n;
    double xi,xs,ys,xt,yt;
    scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt);
    scanf("%d",&n);
    a[0][0]=xs;a[0][1]=ys;a[0][2]=0;
    a[n+1][0]=xt;a[n+1][1]=yt;a[n+1][2]=0;
    for(i=1;i<=n;i++)
        scanf("%lf%lf%lf",&a[i][0],&a[i][1],&a[i][2]);
    n++;
    for(i=0;i<=n;i++)
        for(j=i+1;j<=n;j++)
            f[i][j]=f[j][i]=max(0.0,sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]))-a[i][2]-a[j][2]);//
    fill(dis,dis+1005,1e18);//
    dis[0]=0;
    for(i=0;i<=n;i++){
        xi=1e18;//
        k=0;
        for(j=0;j<=n;j++){
            if(b[j]==0&&dis[j]<xi){
                xi=dis[j];
                k=j;
            }
        }
        b[k]=1;
        for(j=0;j<=n;j++)
            dis[j]=min(dis[j],dis[k]+f[k][j]);
    }
    printf("%.9lf\n",dis[n]);//
}


Measured memory_bytes: 8064
use std::io::prelude::*;

fn input<T>() -> T
where
        T: std::str::FromStr,
{
        let stdin = std::io::stdin();
        let token: String = stdin
                .lock()
                .bytes()
                .map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect();
        token.parse().ok().unwrap()
}

fn main() {
        let n: usize = input();
        println!("{:?}", n * (n-1)/2);
}


Measured memory_bytes: 4352
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
const string bl = " ";

int main() { 

	long A, B, Q; cin >> A >> B >> Q;
	long S[100009], T[100009], X[100009];

	for (int i = 1; i <= A; i++) cin >> S[i];
	S[0] = INT_MIN; S[A + 1] = INT_MAX;

	for (int i = 1; i <= B; i++) cin >> T[i];
	T[0] = INT_MIN; T[B + 1] = INT_MAX;
    S[0] *= 100; S[A + 1] *= 100; T[0] *= 100; T[B + 1] *= 100;
	for (int i = 1; i <= Q; i++) cin >> X[i];


	for (int i = 1; i <= Q; i++) {
		auto Es = (lower_bound(S, S + A + 2, X[i]));
		auto Et = (lower_bound(T, T + B + 2, X[i]));
		auto Ws = Es; Ws--;
		auto Wt = Et; Wt--;
        
		long res = INT_MAX; res *= 100;
		res = min(res,min(abs(*Es - X[i]),abs(*Et - X[i])) + abs(*Es - *Et));
        res = min(res,min(abs(*Ws - X[i]),abs(*Et - X[i])) + abs(*Ws - *Et));
        res = min(res,min(abs(*Es - X[i]),abs(*Wt - X[i])) + abs(*Es - *Wt));
        res = min(res,min(abs(*Ws - X[i]),abs(*Wt - X[i])) + abs(*Ws - *Wt));
		cout << res << endl;
	}
}

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

int N;
int M;
pair<int,int> PD[10000+10];

int main() {
  while (cin >> N >> M && N) {
    int d,p;
    for (int i=0;i<N;i++) {
      cin >> d >> p;
      PD[i] = make_pair(p,d);
      //PD[i].firstは道iの危険度
      //PD[i].secondは道iの長さ
    }
    sort(PD,PD+N);
    reverse(PD,PD+N);
    //    for (int i=0;i<N;i++) {
    //  cout << "kiken: " << PD[i].first << endl;
    //  cout << "nagasa: " << PD[i].second << endl;
    //}
    int S=0; // 全部足してから引く
    for (int i=0; i<N; i++) {
      S += PD[i].first * PD[i].second;
    }
    for (int i=0; i<N; i++) {
      if (M <= 0) {
	break;
      } else {
	int guarded = min(M,PD[i].second);
	S -= PD[i].first * guarded;
	M -= guarded;
      }
    }
    cout << S << endl;
  }
}

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

int main()
{
	int a,b;
	int n;
	while(cin >> a >> b >> n){
		int sum=0;
		a = a%b;
		for(int i=1;i<=n;i++){
			if(a==0)
				break;
			if(a/b == 0)
				a = a*10;
			else
				a = (a%b)*10;
			sum += a/b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  rep(i,N) cin >> C[i];
  sort(all(A));
  sort(all(B));
  sort(all(C));

  ll ans = 0;
  vector<ll> BC(N);
  vector<ll> AB(N);
  for(int i=0;i<N;i++){
    AB[i] = lower_bound(all(A),B[i]) - A.begin();
    BC[i] = lower_bound(all(B),C[i]) - B.begin();
  }
  /*
  rep(i,N) cout << AB[i] << " ";
  cout << endl;
  rep(i,N) cout << BC[i] << " ";
  cout << endl;
  */
  vector<ll> sums(N);
  ll tmp = 0;
  rep(i,N){
    tmp += AB[i];
    sums[i] = tmp;
    //cout << sums[i] << " ";
  }
  //cout << endl;
  rep(i,N){
    if(BC[i]==0)continue;
    ans += sums[BC[i]-1];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, mass, count;
  cin >> N;
  mass = 0;
  count = 0;
  
  vector<int> diff(N);
  for(int i = 0; i < N; i++){
    cin >> diff.at(i);
  }
  sort(diff.begin(), diff.end());
  
  
  count = diff.at(N / 2) - diff.at(N / 2 - 1);
  
  cout << count << endl;
  
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

		System.out.println(Math.max(a *b, c * d));
    }

}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
using namespace std;
long long n, W, w[105], v[105], i, dp[105][100005], j, mx, sum;
int main() {
	cin >> n >> W;
	for (i = 0;i < n;++i)cin >> w[i] >> v[i], sum += v[i];
	for (i = 0;i <= sum;++i)dp[0][i] = 10e9;
	for (i = 0;i < n;++i) { 
		for (j = 0;j < v[i] - 1;++j)dp[i + 1][j] = dp[i][j];
		for (j = v[i]-1;j <= sum;++j)dp[i + 1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j]);
	}
	for (j = 0;j <= sum;++j)if (dp[n][j] <= W&&dp[n][j] != 10e9)mx = max(mx, j);
	cout << mx + 1;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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 ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int N; cin >>N;

  int prev_t=0,prev_x=0,prev_y=0;
  rep(i,0,N) {
    int t,x,y; cin >>t >>x >>y;

    int check_t=t-prev_t;
    int check_pos=abs(x-prev_x)+abs(y-prev_y);

    if (check_t<check_pos || check_t%2!=check_pos%2) {
      cout <<"No" <<'\n';
      return 0;
    }
    prev_t=t; prev_x=x; prev_y=y;
  }

  cout <<"Yes" <<'\n';
  return 0;
}


Measured memory_bytes: 3588
import java.util.*;

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

        Integer[] numList = new Integer[n];
        for (int i = 0; i < n; i++) {
            numList[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(numList, Collections.reverseOrder());
        int sumAlice = 0;
        int sumBob = 0;
        for (int i = 0; i < numList.length; i++) {
            if (i % 2 == 0) {
                sumAlice += numList[i];
            } else {
                sumBob += numList[i];
            }
        }

        System.out.println(sumAlice - sumBob);
    }
}


Measured memory_bytes: 22868
# https://atcoder.jp/contests/abc129/tasks/abc129_c

n, m = [int(i) for i in input().split()]
broken = set()
MOD = 10**9 + 7
for _ in range(m):
    broken.add(int(input()))

steps = [0] * (n + 1)
steps[0] = 1
if 1 in broken:
    steps[1] = 0
else:
    steps[1] = 1

for i in range(2, n + 1):
    if i in broken:
        steps[i] = 0
    else:
        steps[i] = (steps[i - 1] + steps[i - 2]) % MOD

print(steps[n])


Measured memory_bytes: 86108
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	while (1){
		int n, k;
		cin >> n >> k;
		if (!n and !k) return 0;
		int a[n];
		vector<int> max(n - k);
		REP(i, n) cin >> a[i];
		REP(i, k) max[0] += a[i];
		FOR(i, 1, n-k){
			max[i] = max[i-1] + a[i+k-1] - a[i-1];
		}

		sort(ALL(max), greater<int>());

		cout << max[0] << endl;
	}

}



Measured memory_bytes: 3536
N=int(input())
A=list(map(int,input().split()))

M=max(A)
check=[0]*(M+1)
for i in range(N):
    a=A[i]
    while a<=M:
        check[a]+=1
        a+=A[i]
ans=0
for i in range(N):
    if check[A[i]]==1:
        ans+=1

print(ans)

Measured memory_bytes: 32168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  string s;
  cin>>s;
  cout<<s[0]<<s[1]<<s[2]<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		String[] sarr = s.split("");

		boolean isReached = false;
		int posA = 0;
		int posZ = 0;

		for (int i = 0; i < sarr.length; i++) {

			if(!isReached) {
				if(sarr[i].equals("A")) {
					posA = i - 1;
					isReached = true;
				}
				continue;
			}
			if(sarr[i].equals("Z")) {
				posZ = i;
			}
		}

		System.out.println(posZ - posA);

	}

}


Measured memory_bytes: 54144
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int p,q;
  while(cin>>p>>q) {
    p %= q;
    string ans;
    set<int> se;
    map<int,int> ma;
    
    while(true) {
      if (p==0) {
        cout << ans << endl;
        break;
      }
      if (se.count(p)==1) {
        // cout << "p " << p << endl;
        cout << ans << endl;
        cout << string(ma[p],' ') << string(ans.length()-ma[p],'^') << endl;
        // cout << ma[p] << " " << ans.length() << endl;
        break;
      }
      se.insert(p);
      ma[p] = ans.length();
      
      p*=10;
      ans += '0' + p/q;
      p %= q;
    }
  }
}

Measured memory_bytes: 0
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
N = int(stdin.readline().rstrip())
An = []
xy = {}
count = 0
for el1 in range(N):
    ai = int(stdin.readline().rstrip())
    An.append(ai)
    Tmp = []
    for el2 in range(ai):
        tmp = [int(s) for s in stdin.readline().rstrip().split()]
        Tmp.append(tmp)
    xy[count] = Tmp
    count += 1
Checker = []
for el in range(2 ** N):
    bin(el)
    checker = list(str(bin(el)))
    del checker[0:2]
    checker = [int(s) for s in checker]
    for n in range(N - len(checker)):
        checker.insert(0, 0)
    Checker.append(checker)

res = 0
for el1 in Checker:
    pos = 0
    tes0 = []  # 0のやつを追加
    tes1 = []  # 1のやつを追加
    for el2 in el1:
        if el2 == 0:
            pos += 1
            continue
        else:
            tes1.append(pos)
            n = xy[pos]
            for el3 in n:
                if el3[1] == 1:
                    tes1.append(el3[0]-1)
                if el3[1] == 0:
                    tes0.append(el3[0]-1)
            pos += 1
    check = True
    for el2 in tes1:
        if (el1[el2] != 1):
            check = False

    if (len(set(tes0) & set(tes1)) == 0 and check):
        if (el1.count(1) >= res):
            res = el1.count(1)
print(res)


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

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

  int ans=0;
  for (int i = 0; i < n; i++)
  {
    int h;
    cin >> h;

    if(h>=k) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 110
template <typename T>inline T read()
{
	register T sum=0;
	char cc=getchar();
	int sym=1;
	while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
	if(cc=='-')sym=-1,cc=getchar();
	sum=sum*10+cc-'0';
	cc=getchar();
	while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
	return sym*sum;
}
template <typename T>inline T read(T &a)
{
	a=read<T>();
	return a;
}
int maxx,maxxa,maxxb,n,a[maxn],b[maxn],c[maxn];
bool check(int x,int y,int h)
{
	for(int i=1;i<=n;i++)
	{
		int tmp=max(h-abs(x-a[i])-abs(y-b[i]),0);
		if(tmp!=c[i])return false;
	}
	return true;
}
int main()
{
	n=read<int>();
	for(int i=1;i<=n;i++)
	{
		a[i]=read<int>(),b[i]=read<int>(),c[i]=read<int>();
		if(maxx<c[i])
		{
			maxxa=a[i];
			maxxb=b[i];
			maxx=c[i];
		}
	}
	for(int i=0;i<=100;i++) 
		for(int j=0;j<=100;j++)
		{
			int h=maxx+abs(i-maxxa)+abs(j-maxxb);
			if(check(i,j,h))
			{
				printf("%d %d %d\n",i,j,h);
				return 0;
			}
		}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

template<class Key>
using ordered_set = __gnu_pbds::tree<Key, __gnu_pbds::null_type, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int main(){
  long n,k;
  cin>>n>>k;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];
  rep(i,n) vec[i] -= k;
  rep(i,n-1) vec[i+1] += vec[i];

  ordered_set<pair<long,int>> s;
  rep(i,n) s.insert(mp(vec[i],i));

  long ans = 0;
  long prev = 0;
  rep(i,n){
    ans += (n-i) - s.order_of_key(mp(prev,0));
    s.erase(mp(vec[i],i));
    prev = vec[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14336
n, x, y = gets.split.map(&:to_i)

len = Array.new(n, 0)
1.upto(n-1) do |i|
  (i+1).upto(n) do |j|
    len[[j - i, (x - i).abs + (y - j).abs + 1].min] += 1
  end
end

(n - 1).times do |i|
  puts len[i+1]
end


Measured memory_bytes: 1916
/*
 *
 */
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    //freopen("d2.in", "r", stdin);
    string s;
    cin >> s;

    int totalWin = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (i%2 == 0) {
            if (s[i] == 'g') {

            } else {
                totalWin--;
            }
        } else {
            if (s[i] == 'g') {
                totalWin++;
            }
        }
    }

    printf("%d\n", totalWin);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> a, b, c, d;
vector<pair<int, int>> e;

int main()
{
    int n;
    cin>>n;
    ll ans = 0;
    REP(i,n) {
        int ta, tb;
        cin>>ta>>tb;
        a.push_back(ta);
        b.push_back(tb);
        //c.push_back(max(ta, tb) + ta);
        //d.push_back(max(ta, tb) + tb);
        e.push_back({ta + tb, ta});
    }

    SORT(e);

    RREP(i,n) {
        if (i % 2 != n % 2) {
            ans += e[i].second;
            /*if (e[i].first - e[i].second < e[i].second) {
                ans += e[i].second;
            } else {
                ans += e[i].first - e[i].second;
            }*/
            /*int idx = MAX_ELEMENT(c) - c.begin();
            ans += a[idx];
            c[idx] = 0;
            d[idx] = 0;*/
        } else {
            ans -= e[i].first - e[i].second;
            /*if (e[i].first - e[i].second < e[i].second) {
                ans -= e[i].first - e[i].second;
            } else {
                ans -= e[i].second;
            }*/
            /*int idx = MAX_ELEMENT(d) - d.begin();
            ans -= b[idx];
            c[idx] = 0;
            d[idx] = 0;*/
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2028
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string sw[30];

signed main(void){
  int i, j, k, l;
  for(int testcase = 0;;testcase++){
    int(n);
    if(!n)break;
    int3(m, s, d);
    m--; s--;

    rep(i, d)sw[i].clear();
    rep(i, d){
      sc(sw[i]);
      sw[i] = "0" + sw[i] + "0";
    }

    int lis[d + 1][n][2];

    rep(j, n)lis[0][j][0] = j;
    rep(i, d){
      rep(j, n)lis[i + 1][j][0] = lis[i][j][0];
      rep1(j, sw[i].size() - 1)if(sw[i][j] == '1')
        swap(lis[i + 1][j][0], lis[i + 1][j - 1][0]);
    }

    rep(j, n)lis[d][j][1] = j;
    per(i, d){
      rep(j, n)lis[i][j][1] = lis[i + 1][j][1];
      rep1(j, sw[i].size() - 1)if(sw[i][j] == '1')
        swap(lis[i][j][1], lis[i][j - 1][1]);
    }

    rep(k, n)if(m == lis[d][k][0])break;
    if(k == s)pri(0);
    else{
      bool fl = false;
      rep(i, d){
        fl = false;
        rep1(j, n)if(sw[i][j] + sw[i][j - 1] + sw[i][j + 1] == '0' * 3){
          rep(k, n)if(m == lis[i][k][0])break;
          if(k + 1 == j)k++;
          else if(k == j)k--;
          else continue;
          if(lis[i + 1][k][1] == s){
            fl = true;
            break;
          }
        }
        if(fl)break;
      }
      if(fl)pri2(i + 1, j);
      else pri(1);
    }


  }
  return 0;
}

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

struct T {
    bool b = false;
    int w = 0;
} t;

int main() {
    // n problems
    // m submissions

    int n, m;
    int p;
    int correct = 0, penalty = 0, temp = 0;
    std::string s;
    std::cin >> n >> m;
    std::vector<T> a (n+1);
    for(int i = 0; i < m; i++) {
        std::cin >> p >> s;
        if(a[p].b == false) {
            if(s == "AC") {
                correct++;
                a[p].b = true;
            }
            else {
                a[p].w++;
            }
        }
    }

    for(int i = 1; i < a.size(); i++) {
        if(a[i].b) {
            penalty += a[i].w;
        }
    }
    std::cout << correct << " " << penalty;
    // output: #correct #penalties

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 105
#define LL long long
char s[MAXN],t[MAXN];
int main()
{
	int len,pos,ans=0;
	scanf("%d\n",&len);
	scanf("%s %s",s,t);
	for(int i=0;i<len;i++)
	{
		if(s[i]==t[0])
		{
			pos=i+1;
			int cnt=1;
			while(pos<=len-1&&s[pos]==t[cnt])
			{
				pos++;
				cnt++;
			}
			if(pos==len)
			{
				ans=pos-i;
				break;
			}
			//else i=pos;
		}
	}
	printf("%d\n",len+len-ans);
}


Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)
a = Array.new(m){gets.to_i}
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1
a.each do |x|
  dp[x] = -1
end
2.upto(n) do |i|
  next if dp[i] == -1
  dp[i] += [dp[i - 1], 0].max + [dp[i - 2], 0].max
  dp[i] %= 1_000_000_007
end
puts dp[n]

Measured memory_bytes: 15744
x, n = map(int, input().split(' '))
min_num = 100

ls = [0] * 201
for i in range(0, 201):
    ls[i] = i

ls_in = [0] * n
if n > 0:
    ls_in = list(map(int, input().split(' ')))
    for i in ls_in:
        ls.remove(i)
    ls.reverse()
    for i in ls:
        min_num = min(abs(x-i), min_num)
        if abs(x-i) == min_num:
            ans = i 
    print(ans)
else:
    print(x)

Measured memory_bytes: 9200
from collections import defaultdict

N = int(input())
A = [int(i) for i in input().split()]

cnt = defaultdict(int)
for a in A:
    cnt[a] += 1

SUM = 0
for c in cnt.values():
    if c >= 2:
        SUM += c * (c - 1) // 2

for a in A:
    c = cnt[a]
    tmp = c * (c - 1) // 2
    if c > 2:
        tmp -= (c - 1) * (c - 2) // 2
    print(SUM - tmp)

Measured memory_bytes: 26780
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*M;cnt=0
for i in range(M):
  a,b=map(int,input().split())
  A[i]=a,b
A.sort(key=lambda x: x[0])
#print(A)
S=[1]*(N+1)
for i in range(M):
  if H[A[i][0]-1]>H[A[i][1]-1]:
    S[A[i][0]]=min(1,S[A[i][0]])
  else:
    S[A[i][0]]=0
 
#print(S)
for i in range(M):
  if H[A[i][1]-1]>H[A[i][0]-1]:
    S[A[i][1]]=min(1,S[A[i][1]])
  else:
    S[A[i][1]]=0
 
#print(H)
#print(S)
for i in range(1,N+1):
  if S[i]==1:
    cnt=cnt+1
print(cnt)

Measured memory_bytes: 28128
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	
	int a[n+1] = {0};
	for(int i=0;i<k;i++){
		int d;
		cin >> d;
		
		for(int j=0;j<d;j++){
			int t;
			cin >> t;
			
			a[t] = 1;
		}
	}
	
	
	int ans = 0;
	for(int i=1;i<=n;i++)
		if(!a[i])
			ans++;
	
	cout << ans;
}




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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;


int n;
int h[100100];

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

  rep(i, n-1) {
    if (i == 0) {
      h[i]--;
    }
    if (i != 0) {
      if (h[i] > h[i-1]) {
        h[i]--;
      }
    }
  }

  bool can = true;
  rep(i, n-1) {
    if (h[i+1] < h[i]) {
      can = false;
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,Ans=1;
    int T[104];
    cin >> N;
    REP(i,N){cin >> T[i];}
    REP(i,N){
        int a=Ans,b=T[i],r=Ans%T[i];
        while(r!=0){
            a=b;
            b=r;
            r=a%b;
        }
        Ans*=T[i]/b;
    }
    cout << Ans << endl;
    return 0;
}   



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    ll N,S; cin >> N >> S;
    VL A(N); REP(i,N) cin >> A[i];

    ll dp[N+1][S+1]; REP(i,N+1)REP(j,S+1) dp[i][j] = 0;
    dp[0][0] = 1;
    REP(i,N)REP(j,S+1){
        (dp[i+1][j] += 2*dp[i][j]) %= MOD;
        if(j+A[i] <= S) (dp[i+1][j+A[i]] += dp[i][j]) %= MOD;
    }

    cout << dp[N][S] << en;
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 73908
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int A, B, C;

	cin >> A >> B >> C;

	if (A == B && B == C && C == A) {
		cout << "No" << endl;
	} else {
		if (A != B && B != C && C != A) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = new int[nm[1]];
            var isStepAble = new bool[nm[0] + 1];

            int MOD = 1000000007;

            a = a.Select(x => x = int.Parse(Console.ReadLine())).ToArray();

            for (int i = 0; i < isStepAble.Count(); i++)
            {
                isStepAble[i] = true;
            }

            foreach (var x in a)
            {
                isStepAble[x] = false;
            }

            var dp = new int[nm[0] + 1];

            dp[0] = 1;
            dp[1] = isStepAble[1] ? 1 : 0;
            // dp[2] = isStepAble[2] ? dp[1] == 1 ? 2 : 1 : 0;

            for (int i = 2; i < dp.Count(); i++)
            {
                dp[i] = ((dp[i - 1] + dp[i - 2]) % MOD) * (isStepAble[i] ? 1 : 0);
            }
            Console.WriteLine(dp.Last());

        }
    }
}


Measured memory_bytes: 15456
#include<stdio.h>

int main()
{
    int n,i,j,ans,a,b,numa[100010]={0},numb[100010]={0};//バケット
	int maxa1=0,maxa2=0,maxb1=0,maxb2=0,maxnuma,maxnumb;
	scanf("%d",&n);
	for(i=0;i<(n/2);i++)
	{
		scanf("%d",&a);
		scanf("%d",&b);
		numa[a]++;
		numb[b]++;
	}
	for(j=1;j<=100000;j++)
	{
		if(maxa1<numa[j])
		{
			maxa2=maxa1;
			maxa1=numa[j];
			maxnuma=j;
		}
		else if(maxa2<numa[j])
		{
			maxa2=numa[j];
		}
	}
	
	for(j=1;j<=100000;j++)
	{
		if(maxb1<numb[j])
		{
			maxb2=maxb1;
			maxb1=numb[j];
			maxnumb=j;
		}
		else if(maxb2<numb[j])
		{
			maxb2=numb[j];
		}
	}
	
	if(maxnuma!=maxnumb)ans=(n-(maxa1+maxb1));
	else if((maxa1+maxb2)>(maxa2+maxb1))ans=(n-(maxa1+maxb2));
	else ans=(n-(maxa2+maxb1));
	
	printf("%d",ans);
}


Measured memory_bytes: 896
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47372