akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(long long)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    int xma = -101, ymi = 1e8;
    rep(i, N) {
        cin >> x[i];
        xma = max(xma, x[i]);
    }
    rep(i, M) {
        cin >> y[i];
        ymi = min(ymi, y[i]);
    }

    bool ok = false;
    for (int z=X+1; z<=Y; ++z) {
        if (z > xma and z <= ymi) {
            ok = true;
        }
    }

    cout << (ok ? "No War" : "War") << endl;
}


Measured memory_bytes: 256
from itertools import product
N = int(input())
S = input()

C = product("SW", repeat=2)


for c in C:
    ans = list(c)
    for i in range(1, len(S)):
        # 羊
        if ans[-1] == "S":
            # 羊で〇なら同じ
            if S[i] == "o":
                ans.append(ans[-2])
            else:
                # 羊で×ならじゃないほう
                if ans[-2] == "S":
                    ans.append("W")
                else:
                    ans.append("S")
        # 狼
        else:
            # 狼で×なら同じ
            if S[i] == "x":
                ans.append(ans[-2])
            # 狼で〇ならじゃないほう
            else:
                if ans[-2] == "S":
                    ans.append("W")
                else:
                    ans.append("S")

    ans = ans[:-1]
    for i in range(N):
        if ans[i] == "S" and S[i] == "o":
            if ans[i-1] != ans[(i+1) % N]:
                break
        if ans[i] == "S" and S[i] == "x":
            if ans[i-1] == ans[(i+1) % N]:
                break
        if ans[i] == "W" and S[i] == "x":
            if ans[i-1] != ans[(i+1) % N]:
                break
        if ans[i] == "W" and S[i] == "o":
            if ans[i-1] == ans[(i+1) % N]:
                break
    else:
        print("".join(ans))
        break

else:
    print(-1)


Measured memory_bytes: 60852
//ΔAGC020C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<bitset>
using namespace std;
typedef long long LL;
const int N = 2222;
bitset<N*N> B;
int main()
{
	int n,i,x,s=0;
	B.set(0);
	scanf("%d",&n);
	while(n--){
		scanf("%d",&x);
		s+=x;
		B=B|(B<<x);
	}
	s=(s+1)>>1;
	while(!B.test(s)){
		s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 2816
class Unionfind
  attr_accessor(:par, :size)

  def initialize(n)
    @par = Array.new(n+1)
    (n+1).times do |i|
      @par[i] = i
    end
    @size = Array.new(n+1,1)
  end

  def root(x)
    while @par[x] != x
      x = @par[@par[x]]
      @par[x] = @par[@par[x]]
    end
    x
  end

  def unite(x,y)
    rx = root(x)
    ry = root(y)
    if rx != ry
      @size[ry] += size(rx)
      @par[rx] = ry
    end
  end

  def same(x,y)
    return root(x)==root(y)
  end

  def size(x)
    if @par[x] == x
      @size[x]
    else
      size(root(par[x]))
    end
  end

end
N,M = gets.chomp.split(" ").map(&:to_i)
a,b = M.times.map{gets.split.map(&:to_i)}.transpose
tree = Unionfind.new(N)
M.times do |i|
  tree.unite(a[i],b[i])
end
max = 0
N.times do |i|
  max = [tree.size(i+1),max].max
end
puts max

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

int main() {
    int n,k;
    cin >> n >> k;
    if(n%k == 0) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(int argc,char* argv[]){
  int number,input,count=0;
  vector<int> values;
  cin >> number;
  for(int i=0;i<number;i++){
    cin >> input;
    values.push_back(input);
  }
  for(int i=0;i<number-1;i++){
    for(int j=number-1;j>i;j--){
      if(values[j-1]>values[j]){
        swap(values[j-1],values[j]);
        count++;
      }
    }
  }
  for(int i=0;i<number;i++){
    if(i==number-1) cout << values[i] << endl;
    else cout << values[i] << " ";
  }
  cout << count << endl;
}

Measured memory_bytes: 3120
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    int t1[10], t2[10][10], t3[10][10][10];
    for(int i=0; i<=9; i++){
        t1[i] = 0;
        for(int j=0; j<=9; j++){
            t2[i][j] = 0;
            for(int k=0; k<=9; k++){
                t3[i][j][k] = 0;
            }
        }
    }
    for(int x=n-1; x>=0; x--){
        int buf = s[x] - '0';
        for(int i=0; i<=9; i++){
            for(int j=0; j<=9; j++){
                if(t3[i][j][buf] == 0 && t2[i][j] == 1){
                    t3[i][j][buf] = 1;
                }
            }
        }
        for(int i=0; i<=9; i++){
            if(t2[i][buf] == 0 && t1[i] == 1){
                t2[i][buf] = 1;
            }
        }
        if(t1[buf] == 0){
            t1[buf] = 1;
        }
    }
    int ans = 0;
    for(int i=0; i<=9; i++){
        for(int j=0; j<=9; j++){
            for(int k=0; k<=9; k++){
                if(t3[i][j][k]){
                    ans++;
                }
            }
        }
    }
    printf("%d", ans);

    return 0;
}

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

int main()
{
    int n, b;
    cin >> n;
    vector<int> vec(n);
    for (int i=0; i<n; i++){
        int a;
        cin >> a;
        vec.at(i) = a;
    }
    int cnt = 0;
    int loc;
    loc = 1;
    for (int i=0; i<n; i++){
        if (loc != 2 ) {
            loc = vec.at(loc-1);
            cnt++;
        } else {
            cout << cnt << endl;
            break;
        }
    }
    if (loc != 2 ) {
         cout << -1 << endl;
    }
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N = int(input())
H = [int(item) for item in input().split()]

c_height = -1
for h in H:
    if h - 1 >= c_height:
        c_height = h - 1
    elif h == c_height:
        pass
    else:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 14252
import java.util.*;
import java.lang.String;


public class Main {
    static class Position {
        public Position(int x, int y) {
            this.x = x; this.y = y;
        }
        public int x;
        public int y;
    }

    static int solve(String[] G) {
        int H = G.length;
        int W = G[0].length();
        int INF = Integer.MAX_VALUE/2;
        int[][] step = new int[H][W];
        ArrayList<Position> starts = new ArrayList<Position>();
        for (int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                step[i][j] = INF;
                if (G[i].charAt(j) == '#') {
                    starts.add(new Position(i, j));
                }
            }
        }

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

        ArrayDeque<Position> que = new ArrayDeque<Position>();

        for (int i = 0; i < starts.size(); i++) {
            que.addLast(starts.get(i));
            step[starts.get(i).x][starts.get(i).y] = 0;
        }

        int res = 0;
        while (!que.isEmpty()) {
            Position pos = que.removeFirst();
            int x = pos.x; int y = pos.y;
            for (int i=0; i<dx.length; i++) {
                int nx = x + dx[i]; int ny = y + dy[i];
                if (nx<0 || H<=nx || ny<0 || W<=ny) {
                    continue;
                }

                if (step[nx][ny] > step[x][y] + 1) {
                    step[nx][ny] = step[x][y] + 1;
                    que.addLast(new Position(nx, ny));
                    res = Math.max(res, step[nx][ny]);
                }
            }
        }

        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        String[] A = new String[H];
        for (int i=0; i<H; i++) {
            A[i] = sc.next();
        }

        int ans = solve(A);

        System.out.println(ans);
    }
}



Measured memory_bytes: 73400
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        int ans = 0;
        boolean h = false;
        for (char c : s.toCharArray()) {
            if (h && c == 'g')
                ans++;
            else if (!h && c == 'p')
                ans--;
            h = !h;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27120
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n;cin>>n;
  double ans;
  if(n%2==0){
    int tmp=n/2;
    ans=(double)tmp/n;
  }else{
    int tmp=n/2+1;
    ans=(double)tmp/n;
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string a,b,c="AKIHABARA";
  bool q=false;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(i==0&&a[i]!='A') b+='A';
    b+=a[i];
    if((a[i]=='H'||a[i]=='B'||a[i]=='R')&&b.size()>=3){
      if(a[i+1]!='A') b+='A';
    }
  }
  for(int i=0;i<c.size();i++){
    if(b[i]!=c[i]) q=true;
  }
  if(!q&&b.size()==c.size()) cout<<"YES";
  else cout<<"NO";
  cout<<"\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

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();

        if (a + b <= k) {
            System.out.println("0 0");
            return;
        }
        if (a > k) {
            System.out.println(String.format("%s %s", a-k, b));
            return;
        }
        
        b = b- (k - a);
        a = 0;
        System.out.println(String.format("%s %s", a, b));

    }
}


Measured memory_bytes: 21716
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        var b = new int[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            a[i] = int.Parse(line[0]);
            b[i] = int.Parse(line[1]);
        }
        getAns(n, a, b);
    }
    static void getAns(int n, int[] a, int[] b)
    {
        var dp = new int[n, n];
        for (int i = 0; i  < n; i++)
            for (int j = 0; j < n; j++)
                dp[i, j] = i == j ? 0 : int.MaxValue;
        for (int i =  n-1; i >=0 ;  i--)
            for (int j = i; j < n; j++)
                for (int k = i; k < j; k++)
                {
                    dp[i, j] = Min(dp[i, j], dp[i, k] + dp[k + 1, j] + a[i] * b[k] * a[k + 1] * b[j]);
                }
        Console.WriteLine(dp[0, n - 1]);
    }
}


Measured memory_bytes: 17940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int a=t.size();
    for(int i=0;i<=s.size()-t.size();i++)
    {
        int p=0;
        for(int j=0;j<t.size();j++)
        {
            if(t[j]!=s[i+j])
                p++;
        }
        a=min(a,p);
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int zs(int n,int x)
{   int count=0;
	for(int i=1;i<=n;i++)
	{if(x%i==0)count++;}
	 return count;
}
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(zs(n,i)==8&&i%2!=0) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  int a, b;
  cin >> a >> b;
  if ((a+b)%2 == 0) cout << (a+b)/2 << endl;
  else cout << (int)(a+b)/2 + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define sz(x) x.size()

using namespace std;

int main(){
    int n;cin>>n;
    int ans =0;
    for(int i = 0;i <n;i++){
        int x;cin>>x;
        if(x != i+1){
            ans++;
        }
    }
    cout<<((ans<=2)?"YES":"NO");
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
const int N = 1e6 + 1;
int cnt[N];

void sieve()
{
    for (int i = 1; i < N; ++i)
    {
        for (int j = i; j < N; j += i)
            cnt[j]++;
    }
}

int main()
{
    //  freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    sieve();
    int n;
    scanf("%d", &n);
    long long ans = 0;
    for (int c = 1; c < n; ++c)
    {
        ans += cnt[n - c];
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 7712
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    while (1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }        
    }
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	int n,i,a=0;
	char s[1000];
	scanf("%d",&n);
	getchar();
	gets(s);
	for(i=1;i<n-1;i++)
	{
		if(s[i]=='B'&&s[i-1]=='A'&&s[i+1]=='C')
		a++;
	}
	printf("%d",a);
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N, T;
    cin >> N >> T;
    const int inf = 1000000007;
    int ans = inf;
    REP (i, 0, N) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans == inf) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

int A, B, C;
int D;

int main() {
	cin >> A >> B >> C;
	D = A - B;
	if (D >= C) cout << 0 << endl;
	else if (C > D) cout << C - D << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cstdlib>
#include<math.h>
//#include<iostream>
using namespace std;

#define LL long long
LL a,b,c,d,n;
int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	c=min(c,min(a*4,b*2));
	LL ans=0;
	scanf("%d",&n);
	if (c*2<d) ans=n*c;
	else {ans=n/2*d;if (n&1) ans+=c;}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
x,y,a,b,c = gets.chomp.split(" ").map(&:to_i)
p = gets.chomp.split(" ").map(&:to_i).sort.reverse
q = gets.chomp.split(" ").map(&:to_i).sort.reverse
r = gets.chomp.split(" ").map(&:to_i).sort.reverse

pp = p[0..x-1].reverse
qq = q[0..y-1].reverse
ans = (r + pp + qq).sort.reverse

puts ans[0..x+y-1].inject(:+)

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

using namespace std;

const int N=1e5+10;
int dp[N];
int a[N];

int main()
{

    int n,k;
    scanf("%d%d",&n,&k);

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

        dp[0]=0;
        dp[1]=abs(a[0]-a[1]);

        for(int i=2;i<n;i++)
            for(int j=0;j<=min(i,k);j++){

             dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
            }

        printf("%d",dp[n-1]);
}


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

int main(){
    int N,D;
    cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >> X[i][j];
        }
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int N=0;
            for(int k=0;k<D;k++){
            int n = abs(X[i][k]-X[j][k]);
            N += n*n;
            }
            bool flag = false;
            for(int k=0;k*k<=N;k++){
                if(k*k==N){
                    flag = true;
                }
                if(flag){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    const int MAX_K = 1e5;
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    bool dp[MAX_K + 1];
    for(int k = 0; k <= K; k++) {
        dp[k] = false;
        for(int i = 0; i < N; i++) {
            if(k < a[i]) continue;
            dp[k] |= !dp[k - a[i]];
        }
    }
    cout << (dp[K] ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int H,W,i,k;
    while(1){
        cin >> H >> W;
        if(H==0&&W==0) break;{
            for(i=0;i<H;i++){
                for(k=0;k<W;k++){
                    cout << "#";
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
#define lint long long
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
#define P pair<int, int>
#define D pair<double, double>
#define DI pair<double, int>
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

lint gcd(lint a, lint b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

lint n, ans, a = inf;
int main() {
	cin >> n;
	rep(i, n) {
		lint b;
		cin >> b;
		if (b < a) {
			ans = i;
			a = b;
		}
	}
	cout << ans + 1 << endl;
}


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

int main(){
	int cards[50];
	int t[50];
	int s[50];
	int n, r;
	int p, c;
	while(cin >> n >> r, n || r){
		for(int i=0; i < n; i++){
			cards[i] = n-i;
		}
		for(int i=0; i < r; i++){
			cin >> p >> c;
			for(int j=0; j < p-1; j++)
				t[j] = cards[j];
			for(int j=p-1; j < p+c-1; j++)
				s[j-p+1] = cards[j];
			for(int j=0; j < c; j++)
				cards[j] = s[j];
			for(int j=c; j < c+p-1; j++)
				cards[j] = t[j-c];
		}
		cout << cards[0] << endl;
	}
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    for(int i = 0;i < s.size() - 8;i++)
    {
        cout << s[i];
    }
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const ll INF = 2e9;
const int MAX_E = 90005;
const int MAX_N = 305;

ll dist[305][305];

bool warchall_floyd(int N){
    rep(k,N)rep(i,N)rep(j,N){
		if(dist[i][j] > dist[i][k]+dist[k][j]) return true;
    }
	return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	rep(i,n)rep(j,n) cin >> dist[i][j];
    if(warchall_floyd(n)){
		cout << -1 << endl;
		return 0;
	}
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			bool flag = true;
			rep(k,n){
				if(k == i || k == j) continue;
				if(dist[i][j] == dist[i][k]+dist[k][j]){
					flag = false;
					break;
				}
			}
			if(flag) ans += dist[i][j];
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    while (true) {
        int n, x;
        int count = 0;
        
        cin >> n >> x;
        
        if (n == 0 && x == 0) {
            break;
        }
        
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (j <= i) {
                    continue;
                }
                for (int k = 1; k <= n; k++) {
                    if (k <= i || k <= j) {
                        continue;
                    } else if ((i + j + k) == x) {
                        count += 1;
                    }
                }
            }
        }
        
        cout << count << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

constexpr ll MAX = 100010;
ll dp[MAX];

int main(int argc, char **argv)
{
	ll n; cin >> n;
	vector<ll> v(n);
	for (ll i = 0; i < n; ++i) cin >> v[i];
	for (ll i = 0; i < MAX; ++i) dp[i] = INF;
	dp[0] = v[0];

	ll len = 1;
	for (ll i = 1; i < n; ++i)
	{
		if (dp[len-1] < v[i]) dp[len++] = v[i];
		else *lower_bound(dp, dp+len, v[i]) = v[i];
	}
	std::cout << len << std::endl;
}



Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
const int MAXN=60;
long long k;
int n;

struct Floyd{
	long long cnt[MAXN][MAXN];
	Floyd() { memset(cnt,0,sizeof(cnt)); }
};

Floyd operator * (Floyd &a,Floyd &b){
	Floyd res;
	for(int k=1;k<=n;++k)
		for(int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)
				(res.cnt[i][j]+=a.cnt[i][k]*b.cnt[k][j]%MOD)%=MOD;
	return res;
}
Floyd operator ^ (Floyd &a,long long m){
	Floyd res;
	for(int i=1;i<=n;res.cnt[i][i]=1,++i);
	while(m){
		if(m&1) res=res*a;
		m>>=1,a=a*a;
	}
	return res;
}
Floyd A,ans;

int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j) cin>>A.cnt[i][j];
	ans=A^k;
	long long output=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j) (output+=ans.cnt[i][j])%=MOD;
	cout<<output<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std ;
int k,temp;
int g(int x,int y){
	if(y==0){
		return x;
	}
	else{
		return g(y,x%y);
	}
}

int main(){
	
	cin>>k;
	
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int l=1;l<=k;l++){
				temp+=g(i,g(j,l));
			}
		}
	}
	cout<<temp<<endl;
}

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

using I = long long;
const I M = 1e9 + 7;

I power(I m, I n) {
  if(!n) return 1;
  return (n & 1) ? (power(m, n - 1) * m % M) : power(m * m % M, n >> 1);
}
I inverse(I n) {
  return power(n, M - 2);
}

int main() {
  I N;
  string S;
  cin >> N >> S;

  vector<I> dp(N+1);
  dp[0] = 1;
  for(auto i=0; i<N; ++i) {
    vector<I> nex(N+1);
    for(auto j=0; j<N; ++j) {
      (nex[j+1] += 2 * dp[j]) %= M;
      (nex[max(0,j-1)] += dp[j]) %= M;
    }
    swap(nex, dp);
  }

  cout << dp[S.size()] * inverse(power(2, S.size())) % M<< endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<40;
const int INF = 1<<30;
const double PI=acos(-1);
ll mod                = 1e9 + 7;
int main(){
	int n,m;
	int ans=0;
	cin >>n>>m;
	Vi a(m);
	V dp(n+3,0LL);
	input(a);
//	rep(i, m) { a[i]; }
	a.pb(INF);
	dp[0] = 1LL;
	for (int i = 0; i <= n ; i++) {
		if (i == *(lower_bound(all(a), i))) {
			dp[i] = 0LL;
		}
		dp[i] %= mod;
	//	clog << dp[i] << endl;
		dp[i + 1] += dp[i];
		dp[i + 2] += dp[i];
	}

	cout <<dp[n]%mod << endl;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const long long INF = 1e18;
const int MOD = 1000000007;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll fact(ll k){
    ll res=1;
    rep(i,k){
        res*=i+1;
        res%=MOD;
    }
    return res;
}


int main(){
    ll N;
    ll res=0;
    cin>>N;
    ll fac=fact(N-1);
    vector<ll> x(N);
    rep(i,N) cin>>x[i];
    rep(i,N-1){
        res+=((x[N-1]-x[i])*fac % MOD) * modinv(i+1,MOD);
        res%=MOD;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1024
import math

n = int(input())
array = [[int(x) for x in input().split()] for z in range(n)]

cnt = 0

for i, j in array[::-1]:
    if (i+cnt) % j == 0:
        continue
    elif (i+cnt) < j:
        cnt += abs(j - (i + cnt))
    elif (i+cnt) > j:
        cnt += math.ceil((i + cnt) / j) * j - (i+cnt)
print(cnt)


Measured memory_bytes: 21924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int nature(ll a){
  if(a>=0){
  return(a);
  }else{
  return(-1*a);
}
}
int main() {
  ll N,h[N],dp[N];
  cin>>N;
  for(ll i=0;i<N;i++){
    cin>>h[i];
  }
  dp[0]=0;
  dp[1]=nature(h[1]-h[0]);
  for(ll i=2;i<N;i++){
    dp[i]=min(dp[i-1]+nature(h[i]-h[i-1]),dp[i-2]+nature(h[i]-h[i-2]));
  }
  cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 7040
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	const int INF = 1 << 30;
	const int di[4] = { 0,1,0,-1 };
	const int dj[4] = { 1,0,-1,0 };
	int h, w;
	cin >> h >> w;
	vector<string> field(h);
	for (int i = 0; i < h; i++) {
		cin >> field[i];
	}
	// BFS
	int ans = 0;
	vector<vector<int> > d(h, vector<int>(w, INF));
	rep(sx, h) {
		rep(sy, w) {
			rep(i, h) {
				rep(j, w) {
					d[i][j] = INF;
				}
			}
			if (field[sx][sy] == '.') {
				d[sx][sy] = 0;
				queue<P> que;
				que.push(P(sx, sy));

				while (!que.empty()) {
					P pos = que.front();
					que.pop();
					int i = pos.first, j = pos.second;
					for (int k = 0; k < 4; k++) {
						int ni = i + di[k], nj = j + dj[k];
						if (ni < 0 || ni >= h) continue;
						if (nj < 0 || nj >= w) continue;
						if (field[ni][nj] == '#') continue;
						if (d[ni][nj] > d[i][j] + 1) {
							d[ni][nj] = d[i][j] + 1;
							que.push(P(ni, nj));
						}
					}
				}
			/*	rep(i, h) {
					rep(j, w) {
						if (d[i][j] == INF) {
							cout << 'x' <<' ';
						}
						else {
							cout << d[i][j] << ' ';
						}
					}
					cout << endl;
				}*/
				rep(i, h) {
					rep(j, w) {
						if (d[i][j] != INF) {
							ans = max(ans, d[i][j]);
						}
					}
				}
				
			}
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000009LL
#define EPS 1e-8

struct Zone
{
public:
	bool operator<( const Zone& zone ) const
	{
		if( mR == zone.mR )
		{
			return mQuery < zone.mQuery;
		}
		else
		{
			return mR < zone.mR;
		}
	}

	int mL;
	int mR;
	int mQuery;
	int mQueryIndex;
};

int cnt[ 510 ];

int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;
	int ans[ Q ];
	vector<Zone> zones;
	REP( i, M )
	{
		int L, R;
		cin >> L >> R;
		Zone zone;
		zone.mL = L;
		zone.mR = R;
		zone.mQuery = 0;
		zone.mQueryIndex = -1;
		zones.push_back( zone );
	}
	REP( i, Q )
	{
		int p, q;
		cin >> p >> q;
		Zone zone;
		zone.mL = p;
		zone.mR = q;
		zone.mQuery = 1;
		zone.mQueryIndex = i;
		zones.push_back( zone );
	}
	sort( zones.begin(), zones.end() );

	REP( i, zones.size() )
	{
		const Zone& zone = zones[ i ];

		if( zone.mQuery == 1 )
		{
			int sum = 0;
			for( int j = zone.mL; j <= zone.mR; ++j )
			{
				sum += cnt[ j ];
			}
			ans[ zone.mQueryIndex ] = sum;
		}
		else
		{
			++cnt[ zone.mL ];
		}
	}

	REP( i, Q )
	{
		cout << ans[ i ] << endl;
	}

	return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root, NIL;

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

  z = malloc(sizeof(struct 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;
    }
  }
}

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

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


int main(){
  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for ( i=0 ; i<n ; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( strcmp(com, "print") == 0 ){
      sounyuu(root);
      printf("\n");
      kensaku(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25292
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[2][100010];  /* dp[id][i+1] : 先頭からi桁目までで条件を満たすs以下の数の個数。
                                    ただし、id = 0 のとき現時点でsと等しい。
                                    id = 1 のとき現時点でsより小さいことが確定。 */

int main() {
    string s;
    cin >> s;
    ll m = s.size();  // sはm桁とする
    
    dp[0][0] = 1;
    rep(i, m) {
        // a,bのi桁目をa_i,b_iとする
        if(s[i] == '0') {  // sの先頭からi桁目が0のとき
            // (a_i, b_i) = (0, 0) のとき
            dp[0][i+1] += dp[0][i];
            dp[1][i+1] += dp[1][i];
            // (a_i, b_i) = (0, 1), (1, 0) のとき
            dp[1][i+1] += 2*dp[1][i];
        }
        else {  // sの先頭からi桁目が1のとき
            // (a_i, b_i) = (0, 0) のとき
            dp[1][i+1] += dp[0][i] + dp[1][i];
            // (a_i, b_i) = (0, 1), (1, 0) のとき
            dp[0][i+1] += 2*dp[0][i];
            dp[1][i+1] += 2*dp[1][i];
        }
        dp[0][i+1] %= mod;
        dp[1][i+1] %= mod;
    }
    
    out((dp[0][m] + dp[1][m])%mod);
    re0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
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 (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main(){
    //cout << "a" << endl;
    int N; cin >> N;
    ll W; cin >> W;
    ll v[101];
    ll w[101];
    rep(i,N){cin >> w[i] >> v[i];}
    //cout << "i" << endl;

    ll dp[101][100001]; //N*W. 
    rep(i,N){rep(j,W){dp[i][j]=-INF;}}

    dp[0][0]=0;
    dp[0][w[0]]=v[0];
    repi(i,1,N){
        rep(j,W+1){
            chmax(dp[i][j], dp[i-1][j]);
            if (j < w[i]) continue;
            chmax(dp[i][j], dp[i-1][j-w[i]]+v[i]);
        }
    }

    ll res=0;
    rep(i,W+1){chmax(res,dp[N-1][i]);}
    //rep(i,W+1){cout<<dp[N-1][i]<<endl;}
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 79104
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	int[] a = new int[n];
      	for (int i = 0; i < n; i++){
        	a[i] = scan.nextInt();
        }
      	double bunbo = 0.0;
      	for(int i = 0; i < n; i++){
        bunbo += (double)1 / a[i];
        }
      	System.out.print(1 / bunbo);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 

 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 	string s;
 	cin>>s;
 	int ans = 0;
 	int temp = 0;
 	for(int i=0;i<3;i++){
 		if(s[i]=='S'){
 			temp = 0;
 		}
 		else{
 			temp++;
 		}

 		ans = max(ans,temp);
 	}   
 	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
typedef long long ll;
const ll mod=pow(10,9)+7;
int main()
{
  ll n, x, t;
  cin >> n >> x >> t;
  cout << (n+x-1)/x*t << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> mochi(n);
  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    mochi[i]=d;
  }
  set<int> mochimochi(mochi.begin(),mochi.end());

  cout<<mochimochi.size()<<endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

		int totalCount = 0;
		for(int i = 0; i < length-1; i++) {
			String forward = word.substring(0, i+1);
			String back = word.substring(i+1, length);

			Set<String> forwardSet = new HashSet<>();
			Set<String> backSet = new HashSet<>();
			for (char cha : forward.toCharArray()) {
				forwardSet.add(String.valueOf(cha));
			}
			for (char cha : back.toCharArray()) {
				backSet.add(String.valueOf(cha));
			}


			int count = 0;
			for (String val : forwardSet) {
				if (backSet.contains(val)) {
					count++;
				}
			}
			if (count > totalCount) {
				totalCount = count;
			}

		}
		System.out.println(totalCount);

	}
}


Measured memory_bytes: 23252
from collections import deque
n = int(input())
work = []
for i in range(n):
    a = int(input())
    work.append([list(map(int, input().split())) for i in range(a)])
result = 0
for i in range(2**n):
    state = bin(i)[2:].zfill(n)
    honest = []
    unkind = []
    for j in range(n):
        if state[j] == "0":
            unkind.append(j+1)
        else:
            honest.append(j+1)
    flag = True
    for human in honest:
        for x, y in work[human-1]:
            if y == 1 and x in unkind:
                flag = False
                break
            elif y == 0 and x in honest:
                flag = False
                break
        if not flag:
            break
    if flag:
        result = result if result>len(honest) else len(honest)
print(result)

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

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

  int64_t R=0;
  int64_t G=0;
  int64_t B=0;

  for(int i=0;i<N;i++){
    if(S.at(i) == 'R'){
      R++;
    }else if(S.at(i) == 'G'){
      G++;
    }else if(S.at(i) == 'B'){
      B++;
    }
  }

  int64_t ans = R*G*B;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      if(2*j-i<N
      && S.at(i)!=S.at(j)
      && S.at(i)!=S.at(2*j-i)
      && S.at(j)!=S.at(2*j-i)){
        ans--;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    int N;
    cin >> N;
    char s[100];
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    int flag = 0;
    for(int i=0;i<N;i++){
        if(s[i] == 'Y')
            flag = 1;
    }   
    if(flag ==0)
        cout << "Three" << '\n';
    else
        cout << "Four" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define mx 100005
#define ll long long
#define mod 1000000007

int ar[mx];
char ch[mx];

int n,m;

void solve()
{
    ll n;
    cin >> n;
	ll x=100;
	ll re=0;
	while(x<n)
	{
		ll interest=x/100;
		x+=interest;
		re++;
	}
	cout<<re<<endl;
}

int main()
{
    int t=1;
    //scanf("%d",&t);
    while(t--)solve();
    return 0;
}



Measured memory_bytes: 3588
<?php
$n = intval(fgets(STDIN));
$k = intval(fgets(STDIN));
$a = intval(fgets(STDIN));
$b = intval(fgets(STDIN));
$sum = 0;
for($i = 1; $i <= $n; $i++){
    if($i <= $k)
        $sum+=$a;
    else
        $sum+=$b;
}
echo $sum,"\n";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;


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

    ll n, m;
    cin >> n >> m;
    vvll mem(n + 1);
    vll p(m), y(m);
    REP(i, m) {
        cin >> p[i] >> y[i];
        mem[p[i]].push_back(y[i]);
    }
    vector<map<ll, ll>> mp(n + 1);
    REP(i, n + 1) {
        VSORT(mem[i]);
        ll len = mem[i].size();
        REP(j, len) {
            mp[i][mem[i][j]] = j + 1;
        }
    }

    REP(i, m) {
        ll s1 = p[i], s2 = mp[p[i]][y[i]], s = 1000000 * s1 + s2, t = s, d = 0;
        while (t) {
            t /= 10;
            d++;
        }
        REP(j, 12 - d) cout << 0;
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define lmt 600001
int _I(){int x; scanf("%d",&x); return x;}
bool prime[lmt+5];
vector< long > pp;
void seive(){
    //int i,j;
    pp.push_back(2);
    for(long i = 4; i <= lmt; i+=2) prime[ i ] = 1;
    for(long i = 3; i <= lmt; i+=2){
        if(!prime[ i ]){
            pp.push_back(i);
            for(long j = i*3; j <= lmt; j+=i<<1) prime [ j ] = 1;
        }
    }
    prime[0]=prime[1]=1;
}
long long ar[300005];
void Lipu_mira()
{
    int n = _I();
    printf("%d\n",(n*(n+1))/2);
}
int main()
{
    //seive();
    //while(true)
    Lipu_mira();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

const int MaxN = 1e5;
LL n, m;

int main()
{
	scanf("%lld%lld", &n, &m);
	if(max(n, m) - min(n, m) <= 1) printf("Brown\n");
	else printf("Alice\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    string s; cin >> s;
    const int n = s.size();

    auto solve = [](int rc, int lc) {
        vector<int> ret(rc + lc);
        int r = 0, l = 0;
        REP(i, rc + lc) {
            if(abs(i - (rc-1)) % 2 == 0) r++;
            else l++;
        }

        REP(i, rc + lc) {
            if(i == rc - 1) 
                ret[i] = r;
            else if(i == rc)
                ret[i] = l;
            else
                ret[i] = 0;
        }

        return ret;
    };

    vector<int> ans;
    int i = 0;
    while(i < n) {
        int rc = 0, lc = 0;
        while(s[i] == 'R') {
            i++;
            rc++;
        }

        while(s[i] == 'L') {
            i++;
            lc++;
        }

        vector<int> ret = solve(rc, lc);
        REP(j, rc + lc) ans.push_back(ret[j]);
    }

    REP(i, n) cout << ans[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1404
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <set>
using namespace std;
int cei(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}
int main() {
	int d, g;
	cin >> d >> g;
	int p[d], c[d];
	for (int i = 0;i < d;i++) cin >> p[i] >> c[i];
	int ans = 1000000;
	for (int i = 0;i < (1<<d);i++) {
		int cur = 0, cnt =0;
		for (int j = 0;j < d;j++) {
			if (i & (1<<j)) {
				cnt += p[j];
				cur += p[j] * (j + 1) * 100 + c[j];
			}
		}
		for (int j = d - 1;j >= 0;j--) {
			if (cur >= g) break;
			if ((i & (1<<j)) == 0) {
				cnt += min(cei(g - cur, (j + 1) * 100), p[j]);
				cur += min(cei(g - cur, (j + 1) * 100), p[j]) * (j + 1) * 100;
			}
		}
		//cout << i << " " << cnt << endl;
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math

N=int(input())
AB=[list(map(int,input().split())) for i in range(N)]
M=math.factorial(N-1)
k=0

for i in range(N):
    for j in range(N):
        if i!=j:
            k+=((AB[i][0]-AB[j][0])**2 + (AB[i][1]-AB[j][1])**2)**0.5

print(k/N)

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



int main(){
    string s;
    cin>>s;
    char a,b;
    bool ok=true;
    a=s[0];
    rep(i,3){
        b=s[i+1];
        if(a==b) ok=false;
        a=b;
    }
    cout<<(ok? "Good": "Bad")<<endl;
}

Measured memory_bytes: 256
j,o,i,m;main(c){for(;c=~getchar();c&1?o|i?o=i=0,j=1:++j:c&2?++i:(i?j=o=0:0,++o))o<=j&o<=i&m<o?m=o:0;m=!printf("%d\n",m);}

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

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if(a <= 0) {
        int fr = 0 - a;
        int ans = d + fr * c + b * e;
        cout << ans << endl;
    } else {
        int ans = (b - a) * e;
        cout << ans << endl;
    }
}



Measured memory_bytes: 3076