akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in(), k = in();
    int ans = 1;
    rep(i, n)
    {
        if (ans * 2 <= ans + k)
            ans *= 2;
        else
            ans += k;
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Exception;
import java.lang.System;

public class Main {
    public static void main(String[] a) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String s;

        while((s = r.readLine()) != null) {
            for(int i = s.length() - 1; i >= 0; i--) {
                System.out.print(s.charAt(i));
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int h, w;
  cin >> h >> w;
  string s, alf;
  rep (i, w+2) s += '#';
  cout << s << endl;
  rep (i, h) {
    cin >> alf;
    cout << '#' + alf + '#' << endl;
  }
  cout << s << endl;
}



Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
list_S = [0]
ans = 0
for i in range(n):
    list_S.append(list_S[i] + a[i])

list_S.sort() # 昇順に並び替え 計算量はO(NlogN)
pre = list_S[0] # 前の数字
acc = 1 # 今まで何個同じ数字が連続したか
for i in range(1,n+1): # i番目の数字を見る．ちなみに0番目の数字は上2行でもう見た
    if list_S[i] == pre: # 今見ている数字が前の数字と同じなら，accに1加算
        acc += 1
    else: # 違うなら，ansに(acc個の中から2個選ぶ場合の数)を加算
        ans += acc * (acc-1) // 2
        pre = list_S[i]
        acc = 1 # accを初期化

ans += acc * (acc-1) // 2 # 一番最後に連続している数字群を足せていないので，ここで補正

    
print(ans)


Measured memory_bytes: 26136
a = 1;
treat = 0;
n, k = map(int, input().split());
 
data = list(input().split() for l in range(2*k))
 
 
while a <= n:
    b = 0;
    d = 0;
    
    while b < k:
        search = int(data[2*b][0]);
        c = 0;
        
        while c < search:
            x = int(data[2*b+1][c]);
            if x == a :
                d = d + 1;
            c = c + 1
            
        b = b + 1;
        
    if d == 0:
        treat = treat + 1;
        
    a = a + 1;
 
print(treat);

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

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

int main() {
  ll h, w;
  cin >> h >> w;
  ll ans = h * w ;

  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (ans % 2 == 0) {
    ans = ans / 2;
  } else {
    ans = ans / 2 + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			
			final int big = sc.nextInt();
			final int reg = sc.nextInt();
			final int normal = sc.nextInt();
			final int cherry = sc.nextInt();
			final int star = sc.nextInt();
			final int time = sc.nextInt();
			
			if(big == 0 && reg == 0 && normal == 0 && cherry == 0 && star == 0 && time == 0){
				break;
			}
			
			int diff = time;
			int money = 100;
			
			diff -= (5 + 1) * big;
			money += ((15 - 2) * 5 + (15 - 3)) * big;
			
			diff -= (3 + 1) * reg;
			money += ((15 - 2) * 3 + (15 - 3)) * reg;
			
			diff -= normal;
			money += (7 - 3) * normal;
			
			diff -= cherry;
			money += (2 - 3) * cherry;	
			
			//free_game
			diff -= star;
			
			//least is buta
			money -= diff * 3;
			
			System.out.println(money);
			
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e9;

int main(){
    string S;
    bool ans=true;
    cin>>S;
    for(int i=0;i<S.size();i++){
        if(i%2==0 && S.at(i)=='L') ans=false;
        if(i%2==1 && S.at(i)=='R') ans=false;
    }

    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}



Measured memory_bytes: 256
A,B,C,K=input().split()
A=int(A)
B=int(B)
C=int(C)
K=int(K)
if (0<=A)and(0<=B)and(0<=C)and(1<=K<=A+B+C<=2*10**9):
    if K<=A:
        print(K)
    if A<K<=A+B:
        print(A)
    if A+B<K<=A+B+C:
        a=A-(K-A-B)
        print(a)

Measured memory_bytes: 9208
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int pr[maxn];
vector<vector<int> > es;
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  es = vector<vector<int> >(n);
  pr[0] = -1;
  for (int i = 1; i < n; ++i) {
    scanf("%d", pr + i);
    --pr[i];
    es[pr[i]].pb(i);
  }
  return 1;
}

int dfs(int v) {
  vector<int> cur;
  for (int u : es[v]) {
    cur.pb(dfs(u));
  }
  sort(cur.begin(), cur.end());
  reverse(cur.begin(), cur.end());

  int val = 0;
  for (int i = 0; i < sz(cur); ++i) {
    val = max(val, i + 1 + cur[i]);
  }
  return val;
}

void solve() {
  int res = dfs(0);
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 13952
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,i,x,j;cin>>n>>x;
	vector<llint>dp(x+1);dp[x]++;
	vector<int>S(n);
	for(i=0;i<n;i++){cin>>S[i];}
	SO(S);
	for(i=n-1;i>=0;i--){
		int s=S[i];
		vector<llint>ep(x+1);
		for(j=0;j<=x;j++){ep[j%s]+=dp[j];ep[j]+=dp[j]*i;}
		for(j=0;j<=x;j++){dp[j]=ep[j]%mod;}
	}
	llint ans=0;
	for(j=0;j<=x;j++){ans+=dp[j]*j;ans%=mod;}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] Cnt = new int[M];
		int[] Same = new int[M];
		Dictionary<int,int> D = new Dictionary<int,int>();
		for(int i=0;i<N;i++){
			if(D.ContainsKey(A[i]) == false) D.Add(A[i],0);
			D[A[i]]++;
		}
		foreach(var k in D.Keys){
			Cnt[k%M] += D[k];
			Same[k%M] += D[k]/2;
		}
		int ans = 0;
		for(int i=0;i<M;i++){
			int j = M - i;
			if(j < i) continue;
			j %= M;
			if(i == j){
				ans += Cnt[i]/2;
			}else{
				int ma = Cnt[i] > Cnt[j] ? i : j;
				int mi = ma == i ? j : i;
				
				ans += Cnt[mi];
				int rest = Cnt[ma] - Cnt[mi];
				int add = rest >= Same[ma] * 2 ? Same[ma] : rest/2;
				
				ans += add;
			}
		}
		Console.WriteLine(ans);
		
	}
	int N,M;
	int[] A;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}



Measured memory_bytes: 15832
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1,T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using Vote = pair<ll,ll>;
using Unordered_map = unordered_map<Vote, int, pair_hash>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define showvec(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" ";
#define read_input(arr,a,b) for(ll i=a;i<b;i++) cin>>arr[i];
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define SmooothOperatorrrrr()                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);                   
#define deci(n) cout<<fixed<<setprecision(n)
const int mod=998244353;
const int mod2=1000000007;
#define M_PI 3.14159265358979323846
#define LL_MAX 9223372036854775807
#define MAXN 2000001
/**************************************************************************************************/

bool prime[2000005];

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
// Function to find gcd of array of 
// numbers 
int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
    { 
        result = gcd(arr[i], result); 
  
        if(result == 1) 
        { 
           return 1; 
        } 
    } 
    return result; 
}

void Sieve() 
{
    int n=2000004;
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    prime[0]=false;
    for (int p=2; p*p<=n; p++) 
    { 
        if(prime[p]==true)
        {
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }
}

vi primeFactors(int n)
{
    unordered_map<int,int> primes;
    while(n%2==0)
    {
        primes[2]=1;
        n=n/2;
    }
    for(int i=3;i<=sqrt(n);i+=2)
    {
        while(n%i==0)
        {
            primes[i]=1;
            n=n/i;
        }
    }
    if(n>2)
        primes[n]=1;
    vi v;
    for(auto x=primes.begin();x!=primes.end();x++)
        v.pb(x->first);
    return v;
}

int main()
{
    SmooothOperatorrrrr();
    int n;cin>>n;
    int a[n];
    read_input(a,0,n);
    int array_gcd=findGCD(a,n);
    if(array_gcd!=1)
        cout<<"not coprime\n";
    else
    {
        Sieve();
        int ok=1;
        unordered_map<int,bool> check_prime;
        FOR(i,0,n)
        {
            vi v=primeFactors(a[i]);
            FOR(j,0,v.size())
            {
                if(check_prime[v[j]])
                {
                    ok=0;
                    break;
                }
                check_prime[v[j]]=1;
            }
        }
        if(ok)
            cout<<"pairwise coprime\n";
        else
            cout<<"setwise coprime\n";
    }
}

Measured memory_bytes: 12328
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()
#include <string.h>         // strcpy, strcmp()

#define L_WORD 30
#define MAX_P 100

typedef struct word_tbl
{
	char word[L_WORD + 1];
	int n_page;
	int pages[MAX_P];
} word_tbl;

int
cmp_func1(const void *l_, const void *r_)
{
	const word_tbl *l = (const word_tbl*) l_;
	const word_tbl *r = (const word_tbl*) r_;

	return strcmp(l->word, r->word);
}

int
cmp_func2(const void *l_, const void *r_)
{
	const int *l = (const int*) l_;
	const int *r = (const int*) r_;

	if (*l < *r)
		return -1;

	if (*l > *r)
		return 1;

	return 0;
}

int
main(int argc, char **argv)
{
	word_tbl word_t[MAX_P];
	char word[L_WORD + 1];
	int page;
	int i, j;

	int n_word = 0;
	while (scanf("%s %d", word, &page) != EOF)
	{
		for (i = 0; i < n_word; ++i)
		{
			if (strcmp(word, word_t[i].word) == 0)
				break;
		}

		if (i >= n_word)
		{
			strcpy(word_t[n_word].word, word);
			word_t[n_word].n_page = 1;
			word_t[n_word].pages[0] = page;
			n_word++;
		}
		else
			word_t[i].pages[word_t[i].n_page++] = page;
	}

	qsort(word_t, n_word, sizeof(word_tbl), cmp_func1);

	for (i = 0; i < n_word; ++i)
	{
		qsort(word_t[i].pages, word_t[i].n_page, sizeof(int), cmp_func2);
		printf("%s\n", word_t[i].word);
		for (j = 0; j < word_t[i].n_page; ++j)
			printf("%d%c", word_t[i].pages[j], (j < word_t[i].n_page - 1) ? ' ' : '\n' );
	}

	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

ll ans = 0;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n), ab(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    rep(i, n) ab[i] = 0;

    rep(i, a.size()){
        int index = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
        ab[index]++;
    }
    rep(i, n){
        if(i==0) continue;
        ab[i] += ab[i-1];
    }
    rep(i, b.size()){
        int index = upper_bound(c.begin(), c.end(), b[i]) - c.end();
        ans += ab[i] * (index);
    }

    cout << abs(ans) << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)

const int mod = 1000000007;

vector<pair<int, int>> st[30];
int cnts[200005];

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if((x -= mod-a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

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

  long n;
  cin >> n;

  vector<long> t(n);
  vector<long> a(n);
  fillLong(t, n);
  fillLong(a, n);


  mint res = 1;
  bool canDo = true;

  for(int i = 1; i < n-1; i++) {
    if (t[i] > t[i-1] && a[i] > a[i+1] && a[i] != t[i]) {
      canDo = false;
      break;
    }
    if (t[i] > t[i-1] || a[i] > a[i+1]) {
      if (t[i] > t[i-1] && a[i] < t[i]) {
        canDo = false;
        break;
      }
      if (a[i] > a[i+1] && a[i] > t[i]) {
        canDo = false;
        break;
      }
    } else {
      res *= min(a[i], t[i]);
    }
  }
  if (a[0] != t[n-1]) {
    canDo = false;
  }

  cout << (canDo ? res.x : 0) << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<utility>
#include<queue>
using namespace std;
int main() {
	long long n;
	long long dt, dist;
	cin >> n;
	vector<long long>t(n+1);
	vector<long long>x(n+1);
	vector<long long>y(n+1);
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	for (long long i = 1; i < n+1; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	bool flag=true;
	for (long long i = 0; i < n; i++) {
		dt = t[i + 1] - t[i];
		dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (dist % 2 != dt%2||dist>dt) {
			flag = false;
		}

	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}

Measured memory_bytes: 2560
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans+=gcd(a,b,c)
print(ans)

Measured memory_bytes: 69612
import itertools

n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
b = list(itertools.product([1,-1],repeat=3))

t = []
for i in range(len(b)):
    c = []
    for j in range(n):
        total = a[j][0]*b[i][0] + a[j][1]*b[i][1] + a[j][2]*b[i][2]
        c.append(total)
    c.sort(reverse=True)
    t.append(sum(c[:m]))

print(max(t))

Measured memory_bytes: 3384
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
import sys
readline = sys.stdin.buffer.readline
geta = lambda fn: map(fn, readline().split())
gete = lambda fn: fn(readline())

def main():
    N = gete(int)
 
    cur, prev = [0]*3, [0]*3
    
    for _ in range(N):
        a, b, c = geta(int)
        prev, cur = cur, prev
        cur[0] = max(prev[1], prev[2]) + a
        cur[1] = max(prev[2], prev[0]) + b
        cur[2] = max(prev[0], prev[1]) + c
    
    
    print(max(cur))

	
if __name__ == "__main__":
	main()

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

int main(){
  int n;
  cin >> n;
  vector<vector<char>>a(n,vector<char>(10));
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++)
      cin >> a.at(i).at(j);
    sort(a.at(i).begin(),a.at(i).end());
  }
  sort(a.begin(),a.end());
/*for(int i=0;i<n;i++){
    for(int j=0;j<10;j++)
      cout << a.at(i).at(j);
    cout << endl;
  } */
  int64_t ans=0,c=1;
  vector<char>b(10,'/');
  for(int i=0;i<n;i++){
    if(b==a.at(i)){
      c++;
    }else{
      ans+=c*(c-1)/2;
      c=1;
      b=a.at(i);
    }
  }
  ans+=c*(c-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] a = null;
		try(Scanner sc = new Scanner(System.in)){
			// N入力 aスペース区切り入力
			a = new int[sc.nextInt()];
			for(int i = 0; i < a.length; i ++) {
				a[i] = sc.nextInt();
			}
		}
		
		// a要素の4の倍数カウント
		int cnt4 = 0;
		// a要素の2の倍数カウント
		int cnt2 = 0;
		for(int i = 0; i < a.length; i++) {
			
			// 要素が4の倍数
			if(a[i] % 4 == 0) {
				cnt4++;
			}
			// 要素が2の倍数
			else if(a[i] % 2 == 0){
				cnt2++;
			}
		}
		// 2の倍数の数を要素数から排除
		int n = a.length - cnt2;
		
		// 2の倍数が存在した
		if(cnt2 != 0){
			// 偶数
			if(n % 2 == 0) {
				// 4の倍数が要素の半分以上
				if((n /2) <= cnt4) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}				
			} else {
				// 4の倍数が要素の半分より上
				if((n /2) < cnt4) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}				
			}
		} else {
			// 4の倍数が要素の半分以上
			if((n /2) <= cnt4) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 50348
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    k=int(input())
    if s[0]!='1':
        print(s[0])
    else:
        cnt=0
        tugi=''
        for i in s:
            if i=='1':
                cnt+=1
            else:
                tugi=i
                break
        if cnt>=k:
            print('1')
        else:
            print(tugi)
resolve()

Measured memory_bytes: 38256
package main

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

func main() {
	n := readI()
	s := make(map[string]int)
	for i := 0; i < n; i++ {
		tmp := readS()
		if _, ok := s[tmp]; ok {
			s[tmp]++
		} else {
			s[tmp] = 1
		}
	}
	max := 0
	maxS := make([]string, 0)
	for k, v := range s {
		if v > max {
			max = v
			maxS = make([]string, 1, v)
			maxS[0] = k
			continue
		} else if v == max {
			maxS = append(maxS, k)
		}
	}
	sort.Strings(maxS)
	for i := 0; i < len(maxS); i++ {
		fmt.Println(maxS[i])
	}
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 32552
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#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 ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    ll x=1,g=0,n,h,w,k,m,ans=0,ptr=0;
    string s,s1,s2;
    cin >> n;
    VI l(n);
    rep(i,n){
        cin >> l[i];
	}
    sort(ALL(l));

    for(int i=n-1; i>=0; i--){
        for(int j=0; j<i;j++){
            for(int k=j+1; k<i;k++)
                if(l[i] < l[j]+l[k])
                    ans++;
        }
    }
    /*for(int i=0; i<n-2; i++){
        if(l[i+2] < l[i]+l[i+1] && l[i+1] < l[i+2]+l[i] && l[i] < l[i+1]+l[i+2] )
            ans++;
    }*/
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl

signed main() {
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N);
  REP(i,N) {
    cin >> A[i];
    --A[i];
  }
  int c = 0;
  REP(i,N) {
    if(A[A[i]] == i) ++c;
  }
  cout << c / 2 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
int x=D(),a=D(),b=D();
if(abs(x-a)<abs(x-b))
    cout<<"A"<<endl;
else
    cout<<"B"<<endl;
}


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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

const long kMaxN = 1e5 + 5;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  const L kMod = 1000000007;
  S s, t;

  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if (s < t) { cout << "Yes\n"; }
  else { cout << "No\n"; }

  return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val Array( need_num, create_num, create_time ) = scala.io.StdIn.readLine.split( " " ).map{ _.toInt }
    var total_time = ( need_num/create_num )*create_time
    if( need_num%create_num != 0 ) total_time += create_time
    println( total_time )
  }
}

Measured memory_bytes: 54752
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

N,A,B = map(int,input().split())
v = sorted(list(map(int,input().split())),reverse=True)

"""
if len(set(v)) == 1:
    print(1)
    print(1125899906842623)
    exit()
"""

m = sum(v[:A])/A
print(m)

if len(set(v[:A]))==1:
    ans = 0
    c = v.count(v[0])
    for i in range(A,B+1):
        if i <= c:
            ans += cmb(c,i)
    print(ans)
    exit()

mi = min(v[:A])
n = v[:A].count(mi)
m = v.count(mi)
print(cmb(m,n))

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

int main(){
  int N;
  cin >> N;
  set<string> A;
  
  rep(i, N){
    string S;
    cin >> S;
    if(!A.count(S)) A.insert(S);
  }
  
  cout << A.size() << endl;  

}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

void add(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x += y;
    if (x>=mod) x%=mod;
}

int n, x;
int a[maxn];
const int N = 1e5;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>x;
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    vector<ll> dp(N+10, 0);
    dp[x] = 1;
    
    for (int i=0; i<n; i++) {
	vector<ll> _dp(N+10);
	for (int x=0; x<=N; x++) {
	    if (dp[x]==0) continue;
	    // use a[i]
	    add(_dp[x%a[i]], dp[x]);
	    // don't use a[i]
	    add(_dp[x], 1ll*(n-i-1)*dp[x]%mod);
	}
	swap(_dp, dp);
    }

    ll res = 0;
    for (int x=0; x<=N; x++) {
	add(res, 1ll*x*dp[x]);
    }
    cout<<res<<endl;    
    
    return 0;
}


Measured memory_bytes: 4764
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e5 + 10, inf = 1e9;

int tree[4 * N], b[N], c[N];
vector <int> queries[N];

void tree_update(int i, int l, int r, int p, int x);
int tree_query(int i, int l, int r, int ql, int qr);

int main() {
	fast_cin();
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> b[i];
		if (b[i]) {
			c[i] = 1;
		} else {
			c[i] = -1;
			++sum;
		}
	}

	tree_update(1, 0, n, 0, 0);
	for (int i = 1; i <= n; ++i) {
		tree_update(1, 0, n, i, inf);
	}

	// for (int i = 0; i <= n; ++i) {
	// 	cout << tree_query(1, 0, n, i, i) << ' ';
	// }
	// cout << endl;

	int q;
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		queries[l].pb(r);
	}

	for (int i = 1; i <= n; ++i) {
		sort(queries[i].begin(), queries[i].end(), greater<int>());
		for (auto &r : queries[i]) {
			int temp = tree_query(1, 0, n, i - 1, r);
			tree_update(1, 0, n, r, temp);
			// cout << i - 1 << ' ' << r << endl;
		}

		int temp = tree_query(1, 0, n, i - 1, i - 1) + c[i];
		if (tree_query(1, 0, n, i, i) > temp) {
			tree_update(1, 0, n, i, temp);
		}
	}

	cout << sum + tree_query(1, 0, n, n, n) << endl;
}

void tree_update(int i, int l, int r, int p, int x) {
	if (l == r) {
		tree[i] = x;
		return;
	}

	int mid = (l + r) / 2, lc = 2 * i, rc = 1 + lc;
	if (p <= mid) {
		tree_update(lc, l, mid, p, x);
	} else {
		tree_update(rc, mid + 1, r, p, x);
	}
	tree[i] = min(tree[lc], tree[rc]);
}

int tree_query(int i, int l, int r, int ql, int qr) {
	if (l > qr or ql > r) {
		return inf;
	} else if (ql <= l and r <= qr) {
		return tree[i];
	}

	int mid = (l + r) / 2, lc = 2 * i, rc = 1 + lc;
	return min(tree_query(lc, l, mid, ql, qr), tree_query(rc, mid + 1, r, ql, qr));
}

Measured memory_bytes: 14208
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, r, ans;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> r;
    if (n >= 10) ans = r;
    else {
        ans = 100 * (10 - n) + r;
    }
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static BufferedReader in;
    static long max = 0;

    public static void solve() throws IOException {
        Integer[] mn = nextArray(2);
        int m = mn[0];
        int n = mn[1];

        char[][] maze = new char[m][n];

        for (int i = 0; i < m; i++) {
            maze[i] = in.readLine().toCharArray();
        }

        out:
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (maze[i][j] == '#') continue;
                bfs(i, j, maze);

            }
        }

        System.out.println(max);


    }

    private static void bfs(int i, int j, char[][] maze) {
        Queue<List<Integer>> q = new LinkedList<>();
        q.add(Arrays.asList(i, j));

        Set<List<Integer>> visited = new HashSet<>();
        visited.add(Arrays.asList(i,j));

        long moves = 0;
        while (!q.isEmpty()) {
            Queue<List<Integer>> next = new LinkedList<>();

            while (!q.isEmpty()) {
                List<Integer> curr = q.poll();
                int x = curr.get(0);
                int y = curr.get(1);




                List<Integer> t1 = (Arrays.asList(x+1,y));
                List<Integer> t2 =(Arrays.asList(x,y+1));
                List<Integer> t3 =(Arrays.asList(x-1,y));
                List<Integer> t4 =(Arrays.asList(x,y-1));

                if(valid(t1,maze,visited)){next.add(t1);
                visited.add(t1);}
                if(valid(t2,maze,visited)){next.add(t2);
                    visited.add(t2);
                }
                if(valid(t3,maze,visited)){next.add(t3);
                    visited.add(t3);}
                if(valid(t4,maze,visited)){next.add(t4);
                    visited.add(t4);}


            }
            if(next.isEmpty())break;
            moves++;

            q = next;
        }

        max = Math.max(moves,max);

    }

    static boolean valid(List<Integer> curr, char[][] maze,Set<List<Integer>> visited){
        int x = curr.get(0);
        int y = curr.get(1);
        if (x < 0
                || y < 0
                || x >= maze.length
                || y >= maze[0].length
                || visited.contains(curr)
                || maze[x][y] == '#')
            return false;

        return true;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        solve();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(in.readLine().trim());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(in.readLine().trim());
    }

    static Integer[] nextArray(int n) throws IOException {
        StringTokenizer st = new StringTokenizer(in.readLine());
        Integer[] tmp = new Integer[n];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Integer.parseInt(st.nextToken());
        }

        return tmp;
    }

}



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

int main(){
    int n;
    cin >> n;
    
    vector<long long> a(n);
    
    for (int i = 0; i < n; i++) cin >> a[i];
    
    // posi -> negative -> posi .... の場合に関して,操作回数を調べる
    long long cost1 = 0;
    long long sum1 = 0;
    for (int i = 0; i < n; i++){
        
        sum1 += a[i];
        
        if (i % 2 == 0 && sum1 > 0) continue;
        else if (i % 2 == 0 && sum1 <= 0){
            cost1 += abs(sum1) + 1;
            sum1 = 1;
        }
        else if (i % 2 == 1 && sum1 >= 0){
            cost1 += abs(sum1) + 1;
            sum1 = -1;
        }
        else{
            continue;
        } 
    }
    
     // negative -> positive -> negative .... の場合に関して,操作回数を調べる
    long long cost2 = 0;
    long long sum2 = 0;
    for (int i = 0; i < n; i++){
        
        sum2 += a[i];
        
        if (i % 2 == 0 && sum2 >= 0){
            cost2 += abs(sum2) + 1;
            sum2 = -1;
        }
        else if (i % 2 == 0 && sum2 < 0){
           continue;
        }
        else if (i % 2 == 1 && sum2 > 0){
           continue;
        }
        else{
            cost2 += abs(sum2) + 1;
            sum2 = 1;
        } 
    }
    
    long long ans = min(cost1, cost2);
    cout << ans << endl;
}


Measured memory_bytes: 1024
using System;


namespace Gushwell.Etude
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            var lcm = Lcm(2, N);
            Console.WriteLine(lcm);
        }

        // 最小公倍数
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    rep(i, 2) {
        if (A >= B) {
            ans += A;
            A--;
        }else {
            ans += B;
            B--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,i,j;
    double ans = 0;
    cin >> N;
    int X[N],Y[N];
    for(i = 0;i < N;i++){
        cin >> X[i] >> Y[i];
    }
    for(i = 0;i < N - 1;i++){
        for(j = i + 1;j < N;j++){
            ans += sqrtl(abs(X[i] - X[j]) * abs(X[i] - X[j]) + abs(Y[i] - Y[j]) * abs(Y[i] - Y[j]));
        }
    }
    ans *= N - 1;
    ans /= (N * (N - 1) / 2);
    printf("%lf\n",ans);
}

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

int main(){
    std::string str;
    std::cin >> str;

    std::sort(str.begin(), str.end());
    if("abc" == str){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
x = int(input())

if 400 <= x < 600:
    print('8')
elif 600 <= x < 800:
    print('7')
elif 800 <= x < 1000:
    print('6')
elif 1000 <= x < 1200:
    print('5')
elif 1200 <= x < 1400:
    print('4')
elif 1400 <= x < 1600:
    print('3')
elif 1600 <= x < 1800:
    print('2')
elif 1800 <= x < 2000:
    print('1')

Measured memory_bytes: 61640
#include<iostream>

using namespace std;

void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){

	int data[10][10];

	int h;

	while(cin>>h){
		if(h==0)break;

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

		int ans=0;
		while(1){
			int flag=0;
			for(int i=0;i<h;i++){
				for(int j=0;j<5;j++){
					if(data[i][j]==0)continue;
					int num = data[i][j];
					int cnt=1;

					for(int k=j+1;k<5;k++){
						if(num==data[i][k]){
							cnt++;
						}
						else{
							break;
						}
					}
					if(cnt>=3){
					//	cout<<"unko"<<endl;
						for(int k=j;k<j+cnt;k++){
							data[i][k]=0;
						}
						ans+= cnt*num;
						flag=1;
					}
				}
			}

			/*
			for(int i=0;i<h;i++){
				for(int j=0;j<5;j++){
					cout<<data[i][j]<<" ";
				}
				cout<<endl;
			}

			*/
		//	cout<<endl<<endl;

			for(int i=h-2;i>=0;i--){
				for(int j=0;j<5;j++){
					if(data[i][j]!=0){
						int flag=1;
						for(int k=i+1;k<h;k++){
							if(data[k][j]==0){
								swap(&data[k][j],&data[k-1][j]);
								flag=0;
							}
						}
						if(flag==0){
							i=h-1;
							j=10;
						}
					}
				}
			}

			/*
			for(int i=0;i<h;i++){
				for(int j=0;j<5;j++){
					cout<<data[i][j]<<" ";
				}
				cout<<endl;
			}

			cout<<endl<<endl;
			*/


			if(flag==0)break;
		}

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

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <string.h>
using namespace std;



int main(){

    int N;
    cin >> N;

    string S[N];
    int P[N], num[N];

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

    for(int i=0;i<N;i++){
        for(int j=N-1;j>i;j--){
            if(S[j].compare(S[j-1]) > 0 ){
                string tmpS = S[j];
                S[j] = S[j-1];
                S[j-1] = tmpS;
                int tmpP = P[j];
                P[j] = P[j-1];
                P[j-1] = tmpP;
                int tmpN = num[j];
                num[j] = num[j-1];
                num[j-1] = tmpN;
            }
        }
    }//昇順のソート

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(S[i]==S[j] && P[i]<P[j]){
                string tmpS = S[i];
                S[i] = S[j];
                S[j] = tmpS;
                int tmpP = P[i];
                P[i] = P[j];
                P[j] = tmpP;
                int tmpN = num[i];
                num[i] = num[j];
                num[j] = tmpN;
            }
        }
    }//Pの比較

    for(int i=N-1;i>=0;i--){
        cout << num[i]+1 << "\n";
    }//昇順を逆順で表示

    return 0;
}

//g++ ファイル名 --input-charset=utf-8 --exec-charset=cp932
//日本語出力するときのやつ

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(int argc, char *argv[])
{
  int n,k;
  scanf("%d %d",&n,&k);
  int res = 1;
  for (int i = 0; i < n; i++) {
    res = min(res*2,res+k);
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 256
N=int(input())

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

K=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            a,b,c=sorted([L[i],L[j],L[k]])
            if a!=b and b!=c and a+b>c:
                K+=1
print(K)


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

vector<long long> divisor(long long n){
    vector<long long> res;
    for(long long i = 1; i*i <= n; i++){
        if(n%i==0){
            res.push_back(i);
            if(n/i != i)res.push_back(n/i);
        }
    }
    return res;
}

int main(){
  int n, m;
  cin >> n >> m;
  auto d = divisor(m);
  ll res = 0;
  for (auto e : d) {
    if (e * n <= m) res = max(res,e);
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<((a==b and b==c)?"Yes":"No")<<endl;
}

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

int N;
const int MAX_N = 100010;
int a[MAX_N];
int b[MAX_N],sz;

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

    for(int i=0,j=1;i<N;i=j++){
        while(a[i]==a[j])j++;
        b[sz++]=j-i;
    }

    int cnt = 0;
    for(int i=0;i<sz;i++){
        cnt += b[i]%2==0;
    }

    printf("%d\n",sz - (cnt%2==1));
    return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1ll << 30ll)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, K, a[100100];
int c[100100];

int add(int x){
    if(x > K)return 0;
    if(c[x]++){
        return 0;
    }
    else {
        return 1;
    }
}

int remove(int x){
    if(x > K)return 0;
    if(--c[x]){
        return 0;
    }
    else {
        return -1;
    }
}

int remove_flag(int x){
    if(x > K)return 0;
    if(c[x] - 1){
        return 0;
    }
    else {
        return -1;
    }
}

signed main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int l = 0, r = 0, s = 0;
    int ans = INF;
    for(r = 0; r < N; r++){
        s += add(a[r]);
        if(s < K){
            continue;
        }
        while(l <= r && s + remove_flag(a[l]) == K){
            s += remove(a[l]);
            l++;
        }
        ans = min(ans, r - l + 1);
    }
    cout << ans % INF << endl;

    return 0;
}

/*


*/


Measured memory_bytes: 4652
#include<bits/stdc++.h>
#include<math.h>
#include<map>
#include<sstream>
#define str string
#define ll long long int
#define con continue

#define rt return 0
#define fr first
#define sec second
#define pf push_front
#define pb push_back
#define vb vct.begin()
#define ve vct.end()
#define ib it.begin()
#define ie it.end()
#define lb lst.begin()
#define le lst.end()
#define mb mp.begin()
#define me mp.end()
#define sb st.begin()
#define se st.end()
#define strb s.begin()
#define stre s.end()


using namespace std;
str s,s1,s2,s3;

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

   //ll tc; cin>>tc;while(tc--){
   ll n,m,z,j,a=0,ans=0,k=0,cnt=0,b;
   ll c=0,x,y,d=0,sum=0,mn=INT_MAX,mx=0;
   str ss,strn;
   char ch;

   cin>>ss;
   if(ss=="RRR")cout<<3<<endl;
   else if(ss=="RRS" || ss=="SRR")cout<<2<<endl;
   else if(ss=="SSS")cout<<0<<endl;
   else cout<<1<<endl;

// }


            return 0;

}











//map<str,ll>mp;
   //map<str,ll>::iterator it;
   /*vector<ll>vct;
   vector<ll>::iterator vit;
   set<ll>st;
   set<ll>::iterator sit;
   priority_queue<ll>pq;
   //priority_queue<ll>::iterator pqit;*/



Measured memory_bytes: 3632