akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int maxN = 200000 + 10;

int main()
{
    long long int a[maxN];
    int n;
    cin >> n;

    for (int i = 0; i < maxN; ++i)
    {
        a[i] = 0;
    }

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

    sort(a, a + n);
    bool flag = true;
    for (int i = 0; i < n - 1; ++i)
    {
        if (a[i + 1] == a[i])
        {
            flag = false;
            break;
        }
    }

    if (flag)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

struct Node {
	int nextNode;
	int happiness;
} typedef tNode;

int main() {
	int n, aux, i, j, a, b;
	scanf("%d", &n);

	int happiness[n][3];
    bool isABigger;

	for (i = 0; i < n; i++) {
		scanf("%d", &aux);
		happiness[i][0] = aux;

        scanf("%d", &aux);
		happiness[i][1] = aux;

        scanf("%d", &aux);
		happiness[i][2] = aux;
	}

    tNode choices[n][3];

    for (i = n - 1; i >= 0; i--) {
		for (j = 0; j < 3; j++) {
            if (i == n - 1) {
                choices[i][j].happiness = happiness[i][j];
                choices[i][j].nextNode = -1;
            } else {
                a = (j + 1) % 3;
                b = (j + 2) % 3;

                isABigger = choices[i + 1][a].happiness > choices[i + 1][b].happiness;

                choices[i][j].happiness = happiness[i][j] + (isABigger ? choices[i + 1][a].happiness : choices[i + 1][b].happiness);
                choices[i][j].nextNode = isABigger ? a : b;
            }
        }
	}

    aux = -1;
    for (j = 0; j < 3; j++) {
        if (choices[0][j].happiness > aux) {
            aux = choices[0][j].happiness;
        }
    }

    printf("%d\n", aux);

	return 0;
}


Measured memory_bytes: 3712
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int[] c = {0,0,0,0,0};

    int sum = 0 ;

    for(int i = 1 ; i <= N ; i ++){
      c[4] =          i  / 10000 ;
      c[3] = (i % 10000) / 1000  ;
      c[2] = (i % 1000)  / 100   ;
      c[1] = (i % 100)   / 10    ;
      c[0] =  i % 10             ;

      int digitSum = c[0] + c[1] + c[2] +  c[3] + c[4] ;

      if( digitSum  >= A && digitSum <= B ){
        sum = sum + i ;
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 22864
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N;
  cin>>N;
  
  for(ll i=0;i<N;i++) {
ll A;
    cin>>A;
    if(A%2==0) {
if(A%3!=0&&A%5!=0) {
cout<< "DENIED"<<endl;
  return 0;
}
    }
  }
  
  cout<<"APPROVED"<<endl;
}
  
  
  

  


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

int main()
{
        int n;
        cin >> n;
        char ch, oldch = '/';
        int ans = 0;
        for (int i = 0; i < n; ++i)
        {
                cin >> ch;
                if (oldch != ch)
                {
                        oldch = ch;
                        ++ans;
                }
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 200
#define INF INT_MAX
typedef pair<string, int> P;
typedef vector<string> Vec;
 
int N;
vector<P> vec;
 
int cost(Vec v)
{
    int res = 0;
    for (int i = 0; i < (int)v.size(); i++) {
	for (int j = 0; j < N; j++) {
	    if (vec[j].first == v[i]) {
		res += vec[j].second;
		break;
	    }
	}
    }
    return res;
}
 
int main()
{
    int M, K;
 
    while (cin >> N, N) {
	map<string, Vec> mp;
	P in; 
	vec.clear();
	for (int i = 0; i < N; i++) {
	    cin >> in.first >> in.second;
	    vec.push_back(in);
	}
	
	string str, s, item;
	cin >> M;
	for (int i = 0; i < M; i++) {
	    cin >> str >> K;
	    for (int j = 0; j < K; j++) {
		cin >> s;
		mp[str].push_back(s);
	    }
	}    
 
	map<string, Vec>::iterator it;
	for (int i = 0; i < 2; i++) {
	    for (it = mp.begin(); it != mp.end(); ++it) {
		for (int j = 0; j < N; j++) {
		    if (vec[j].first == it->first) {
			vec[j].second = min(vec[j].second, cost(it->second));
		    }
		}
	    }
	}
	cin >> item;
	int ans = INF;
	for (int i = 0; i < N; i++) {
	    if (vec[i].first == item) {
		ans = vec[i].second;
		break;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3176
#include<stdio.h> 
#include<stdlib.h> 
  #include<bits/stdc++.h>
#define N 100005
#define K 200005
#define MOD 998244353
#define ll long long int
using namespace std;
 

int main() 
{ 
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0; 
} 

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    ll n,a,b;
    cin>>n;
    for(int i=sqrt(n);i>0;i--){
        if(n%i==0){
            a=i;
            b=n/i;
            break;
        }
    }
    cout<<a+b-2<<endl;
}

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

int main()
{
    int N = 0, W = 0;
    cin >> N >> W;

    vector<int> w(N + 1, 0), v(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        cin >> w[i] >> v[i];
    }

    ll dp[N + 1][100001];
    for (int i = 0; i < N + 1; i++)
    {
        for (int j = 0; j < 100001; j++)
        {
            dp[i][j] = 2000000000;
        }
    }

    // vector<vector<ll>> dp(N + 1, vector<ll>(100001, 2000000000));
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= 100000; j++)
        {
            if (j < v[i])
            {
                dp[i][j] = dp[i - 1][j];
            }
            else
            {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
    }

    int ans = 100000;
    while (dp[N][ans] > W)
    {
        ans--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll N,M,l,m;
	cin >> N;
	cin >> M;
	vector<P> A(N);
	
	for (ll i = 0;i< N;i++){
		cin >> l;
		cin >> m;
		A[i] = mp(l,m);
	}
	sort(ALL(A));
	ll ans = 0;
	ll res = M;
	for (int i = 0;i<N;i++){
		if (res - A[i].sc <= 0){
			ans += res*A[i].fs;
			break; 
		}
		else{
			res -= A[i].sc;
			ans += A[i].fs * A[i].sc;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    private static final int INF = 1 << 24;
    private static int n;
    private static int[][] d;
    private static int[] p;

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        n = scanner.nextInt();

        p = new int[n+1];

        for (int i = 1; i <= n; i++) {
            int r = scanner.nextInt();
            int c = scanner.nextInt();

            p[i-1] = r;
            p[i] = c;
        }

        matrix_chain_multiplication();

    }

    private static void matrix_chain_multiplication() {
        d = new int[n+1][n+1];

        for (int l = 2; l <= n; l++) {
            for (int i = 1; i <= n - l + 1; i++) {
                int j = i + l - 1;
                d[i][j] = INF;

                for (int k = i; k <= j-1; k++) {
                    d[i][j] = Math.min(d[i][j], d[i][k] + d[k+1][j] + p[i-1] * p[k] * p[j]);
                }
            }
        }

        System.out.println(d[1][n]);
    }
}

Measured memory_bytes: 26668
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int H = sc.nextInt();
        int W = sc.nextInt();
        int A, B;
        int count = 0;
        for (int i = 0; i < N; i++) {
            A = sc.nextInt();
            B = sc.nextInt();
            if (A >= H && B >= W) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 25836
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (d >= abs(c - a)) {
		cout << "Yes";
	}
	else if (d >= abs(b - a) && d >= abs(c - b)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


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

/*long com(long y,long z){
  long p=1;
  long q=1;
  while(z>0){
    p*=y;
    y--;
    q*=z;
    z--;
  }
  return p/q;
}*/

int main(){
  vector<vector<long long>> v(2001,vector<long long>(2001, 0));
  for (int i = 0; i < 2001; i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < 2001; j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%MOD;
    }
  }
      
  int n;
  cin>>n;
  if(n<3) {
    cout<<0;
    return 0;
  }
  int m=n/3;
  long ans=1;
  for(int i=2;i<m+1;i++){
    int k=n-3*i;
    ans+=v[k+i-1][i-1]%MOD;
  }
  cout<<ans%MOD;
}

Measured memory_bytes: 34496
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
const int mod=998244353;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
vector<int>d[101];
map<long long,int>dp[110][2];
int n,dp1[101][101][2];
long long w[101][101][101],t[101];
char s[101];
int solve(int l,int r,bool b,long long p)
{
	if(l==r)return p==-1?s[l]-'0'+1:p+1;
//	printf("%d %d %d %lld\n",l,r,b,p);
	int sum=0;
	if(p==-1)
	{
		if(~dp1[l][r][b])return dp1[l][r][b];
		if(!b)for(int k=l;k<r;++k)sum=(sum+1ll*solve(l,k,1,-1)*solve(k+1,r,0,-1))%mod;
		for(int i:d[r-l+1])add(sum,solve(l,l+i-1,0,w[l][l+i-1][(r-l+1)/i]));
		dp1[l][r][b]=sum;
		return sum;
	}
	else
	{
		if(dp[r-l+1][b].count(p))return dp[r-l+1][b][p];
		if(!b)for(int k=l;k<r;++k)sum=(sum+1ll*solve(l,k,1,p&t[k-l+1])*solve(k+1,r,0,p>>k-l+1))%mod;
		for(int i:d[r-l+1])
		{
			long long np=p&t[i];
			for(int j=1;j<(r-l+1)/i;++j)np&=p>>i*j;
			add(sum,solve(l,l+i-1,0,np));
		}
		dp[r-l+1][b][p]=sum;
		return sum;
	}
}
int main()
{
	memset(dp1,-1,sizeof(dp1));
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n/2;++i)t[i]=(1ll<<i)-1;
	for(int len=1;len<=n/2;++len)
		for(int i=n-len+1,j=n;i;--i,--j)
		{
			for(int k=0;k<len;++k)if(s[i+k]=='1')w[i][j][1]|=1ll<<k;
			for(int k=2;i+k*len-1<=n;++k)w[i][j][k]=w[i][j][1]&w[i+len][j+len][k-1];
		}
	for(int i=1;i<=n;++i)
		for(int j=2*i;j<=n;j+=i)d[j].push_back(i);
	printf("%d",solve(1,n,0,-1));
	return 0;
}

Measured memory_bytes: 11648
# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    A = np.array(args[1].split(), dtype=np.int64)

    n_bit = len(np.binary_repr(max(A)))

    xor = np.bitwise_xor.reduce(A)
    A &= ~xor

    for b in reversed(range(n_bit)):
        b_set = A & 1 << b != 0
        msb_args = np.where(b_set & (A < 1 << b+1))[0]
        if len(msb_args):
            b_set[msb_args[0]] = False
            A[b_set] ^= A[msb_args[0]]

    ret = 2*np.bitwise_xor.reduce(A) + xor

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 30524
#include<iostream>
using namespace std;
int main(){
    int n,x,i,j,k;
    int a=0;
    while(1){
        cin>>n>>x;
        if (n==0 && x==0) break;
        for(i=1;i<=n;i++){
            
            for(j=i+1;j<=n;j++){
                if(j<=i)continue;
                
                for(k=j+1;k<=n;k++){
                    if(k<=j ||k<=i)continue;
                    if(i+j+k==x &&i!=k && j!=k && j!=i){
                        a=a+1;
                    }
                }
                
            }
            
        }
        cout<<a<<endl;
        a=0;
    }
    
    return 0;
}


Measured memory_bytes: 3072
input()
num_list = list(map(int, input().split()))
min_cnt = 999
for num in num_list:
  num_cnt = 0
  while True:
    if num % 2 == 1:
      if num_cnt < min_cnt: min_cnt = num_cnt
      break
    else:
      num = num / 2
      num_cnt += 1
print(min_cnt)

Measured memory_bytes: 3060
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        a: [usize; n],
    }
    let mut dp = a.clone();
    for k in 2..(k + 1) {
        let mut deq = std::collections::VecDeque::new();
        deq.push_back((dp[k - 2], k - 2));
        for i in (k - 1)..n {
            if deq.front().unwrap().1 + m < i {
                deq.pop_front();
            }
            let p = *deq.front().unwrap();
            let b = (dp[i], i);
            dp[i] = p.0 + k * a[i];
            while let Some(p) = deq.pop_back() {
                if p.0 > b.0 {
                    deq.push_back(p);
                    break;
                }
            }
            deq.push_back(b);
        }
    }
    let ans = dp.into_iter().max().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6396
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static long M = 1_000_000_007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		// A G C T
		// 0 1 2 3

		// A -> G

		long[][][][] dp = new long[4][4][4][n - 3 + 1];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					Arrays.fill(dp[i][j][k], 0L);
					dp[i][j][k][0] = 1L;
				}
			}
		}

		dp[0][1][2][0] = 0L; // AGC:A
		dp[0][2][1][0] = 0L; // ACG:A
		dp[1][0][2][0] = 0L; // GAC:A


		for (int m = 0; m < n - 3; m++) {
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					for (int k = 0; k < 4; k++) {
						for (int l = 0; l < 4; l++) {
							dp[j][k][l][m + 1] = (dp[j][k][l][m + 1] + dp[i][j][k][m]) % M;

							dp[0][1][2][m + 1] = 0L;
							dp[0][2][1][m + 1] = 0L;
							dp[1][0][2][m + 1] = 0L;

							if (i == 0) {
								for (int o = 0; o < 4; o++) {
									dp[o][1][2][m + 1] = 0L;
									dp[1][o][2][m + 1] = 0L;
								}
							}
						}
					}
				}
			}
		}

		long answer = 0;
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					answer = (answer + dp[i][j][k][n - 3]) % M;
				}
			}
		}
		System.out.println(answer);

	}
}


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

#define MN 100000
#define FOR(i, n) for (int i = 0; i < n; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back


int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int total = (r * 100) + (g * 10) + (b);
    if (total % 4) {cout << "NO\n";}
    else {cout << "YES\n";} 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 100001

void solve()
{
    lli h,w,k;
    cin>>h>>w>>k;

    string s[h];
    loopl(i,0,h) cin>>s[i];

    lli ans=0;
    loopl(i,0,1<<h)
    {
        loopl(j,0,1<<w)
        {
            lli cnt=0;

            loopl(ii,0,h)
            {
                loopl(jj,0,w)
                {
                    if((1<<ii)&i || (1<<jj)&j) continue;

                    if(s[ii][jj] == '#') cnt++;
                }
            }

            if(cnt == k) ans++;
        }
    }

    cout<<ans<<endl;

}   

int main()
{
////////////////////////////////////////////   
    fastio;
////////////////////////////////////////////
    
    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3652
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

A, B, C = MAP()

if C <= A+B+1:
	print(B+C)
else:
	print(A+2*B+1)


Measured memory_bytes: 10628
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
    int data[255][255];
    int rec[255][255];
    char buf[512];
    int n;
    int i, j, k;
    int ans;
    int dx[4] = {-1, 0, -1, 1};
    int dy[4] = {0, -1, -1, -1};
     
    while (scanf("%d", &n), n){
        for (i = 0; i < n; i++){
            scanf("%s", buf);
            for (j = 0; j < n; j++){
                data[i][j] = buf[j] - '0';
            }
        }
         
        ans = 0;
        for (i = 0; i < 4; i++){
            memset(rec, 0, sizeof(rec));
            for (j = 0; j < n; j++){
                for (k = 0; k < n; k++){
                    rec[j][k] = data[j][k];
                    if (0 <= k + dx[i] && k + dx[i] < n &&
                            0 <= j + dy[i] && j + dy[i] < n && rec[j][k] == 1){
                        rec[j][k] += rec[j + dy[i]][k + dx[i]];
                    }
                    ans = ans > rec[j][k] ? ans : rec[j][k];
                }
            }
        }
         
        printf("%d\n", ans);
    }
	
	return 0;
}

Measured memory_bytes: 1704
m,d=map(int, input().split())
ans=0
if d<=21:
    print(0)
else:
    for i in range(1,m+1):
        for j in range(22,d+1):
            if int(str(j)[0])*int(str(j)[1])==i and int(str(j)[1])>=2:
                ans+=1
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,c=0,m=0;
	string s;
	cin>>n>>s;
	if(1<=n<=100){
	
		for(int i=0;i<n;i++){
			if(s[i]=='I'){
				c++;
			}
			else if(s[i]=='D')
			   c--;
			if(m<c){
			   m=c; 
	}
		
		}
	}
	cout<<m;	
}

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

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

const int MAX=2100000;

long long fac[MAX],finv[MAX],inv[MAX];

//テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

//二項係数の計算
long long COM(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0)  return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
	COMinit();
	int X,Y;
	cin >> X >> Y;

	if((X+Y)%3!=0){
		cout << 0 << endl;
		return 0;
	}
	if(X>2*Y || Y>2*X){
		cout << 0 << endl;
		return 0;
	}

	int mi=abs(X-Y);
	int sum=(X+Y)/3;
	cout << COM(sum,(sum+mi)/2) << endl;

	return 0;
}


Measured memory_bytes: 49408
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int s = Integer.parseInt(sc.next());
        int n = 1;
        if (s == 1 || s == 2) {
            n = 4;
        } else {
            while (s != 4) {
                if (s % 2 == 0) {
                    s /= 2;
                } else {
                    s = s * 3 + 1;
                }
                n += 1;
            }
            n += 3;
        }
        System.out.print(n);
    }
}

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

typedef long long ll;
#define inf 1e9+7

int f[200],d[200];
bool table[200][200];
int cou;

void init(){
    for(int i=0;i<200;i++){
        f[i]=d[i]=-1;
    }
}

void dfs(int n,int itr){
    cou++;
    if(d[itr]<0)d[itr]=cou;
    for(int i=0;i<n;i++){
        if(d[i]<0&&table[itr][i]) dfs(n,i);
    }
    cou++;
    f[itr] = cou;
}

void solve(int n){
    for(int i=0;i<n;i++){
        if(d[i]<0)dfs(n,i);
    }
}

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


    init();
    int u,k,v;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> u >> k;
        for(int j=0;j<k;j++){
            cin >> v;
            table[u-1][v-1]=true;
        }
    }

    solve(n);

    for(int i=0;i<n;i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3176
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Solve()
    {
        var inputs = ReadInts();
        var N = inputs[0]; // N文字
        var K = inputs[1]; // K回
        var S = Read();

        var pattern = new int[N];
        pattern[0] = 0;
        var curChar = '1';
        var cur = 0;

        for (var i = 0; i < N; i++)
        {
            if (S[i] == curChar)
            {
                pattern[cur]++;
            }
            else
            {
                cur++;
                pattern[cur] = 1;
                curChar = curChar == '0' ? '1' : '0';
            }
        }

        if (curChar == '0')
        {
            cur++;
            pattern[cur] = 0;
        }

        if (cur / 2 <= K)
        {
            Console.WriteLine(N);
            return;
        }

        var ans = new int[cur];
        for (var i = 0; i <= 2 * K; i++)
        {
            ans[0] += pattern[i];
        }

        for (var i = 1; 2 * (i + K) <= cur; i++)
        {
            ans[i] = ans[i - 1] + pattern[2 * (i + K) - 1] + pattern[2 * (i + K)]
                - pattern[2 * (i - 1)] - pattern[2 * i - 1];
        }
        Console.WriteLine(ans.Max());
    }

    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

Measured memory_bytes: 14304
#include<iostream>
#include<vector>

using ull = unsigned long long;
using ul = unsigned long;
using sl = signed long;

template<class Container>
auto print(const Container& c) {
	auto end_ = std::end(c);
	for (auto it = std::begin(c);
		it != (end_-1);
		++it) {
		std::cout << *it << " ";
	}std::cout << *(end_ - 1)<< "\n";
}

int main() {
	std::vector<ul> v;

	ul N{};
	std::cin >> N;

	for (ul i{ 0 }; i < N; i++) {
		ul x{};
		std::cin >> x;
		v.emplace_back(std::move(x));
	}

//	print(v);

	for (ul i{ 1 }; i < N; i++) {

		print(v);

		sl k = i - 1;
		ul key = v[i];
		while (k >= 0 && v[k] > key) {
			v[k + 1] = v[k];
			k--;
		}
		v[k + 1] = key;

	}
	print(v);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

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

    set <int> setic;

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

        if(setic.find(a) == setic.end())
        {
            setic.insert(a);
        }

        else
        {
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  set<char>X;
  string flag="no";
  for(int i=0;i<S.size();i++){
    if(X.count(S.at(i))){flag="no";break;}
    else{flag="yes";}
    X.insert(S.at(i));
  }
  cout<<flag<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	a=min(b/a,c);
	printf("%d",a);
	return 0;
}

Measured memory_bytes: 128
import sys

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0

for i in range(3):
    if sum(A[i]) == 0:
        print("Yes")
        sys.exit()

for i in range(3):
    if A[0][i] + A[1][i] + A[2][i] == 0:
        print("Yes")
        sys.exit()

if A[0][0] + A[1][1] + A[2][2] == 0:
    print("Yes")
elif A[0][2] + A[1][1] + A[2][0] == 0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  int table[N][60];
  REP(i,N){
    REP(j,60){
      table[i][j]=(A[i]>>j)&1;
    }
  }

  mint ans = 0;
  REP(i,60){
    int cnt = 0;
    REP(j,N){
      if(table[j][i]==1){
        cnt++;
      }
    }
    mint x = cnt*(N-cnt);
    ans+=x*mint(2).pow(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 75856
N, M = map(int,input().split())

e = [0]*N
for _ in range(M):
  a, b = map(int,input().split())
  if(a == 1):
    e[b] += 1
  elif(b == N):
    e[a] += 1
if(2 in e):
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>> graph(n,vector<int>(n,0));
  rep(i,m){
    int a,b;
    cin >> a >> b;
    --a; --b;
    graph.at(a).at(b) = 1;
    graph.at(b).at(a) = 1;
  }
  vector<int> P(n-1);
  rep(i,n-1) P.at(i) = i+1;
  int ans = 0;
  do{
    bool ok = true;
    int now = 0;
    for(auto x:P){
      if(graph.at(now).at(x) == 0){
        ok = false;
        break;
      }
      now = x;
    }
    if(ok) ans ++;
  }
  while(next_permutation(P.begin(),P.end()));
    
  cout << ans << endl; 
  
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int d;
    cin>>d;
    if(d==25){
        cout<<"Christmas";
    }else if(d==24){
        cout<<"Christmas Eve";
    }else if(d==23){
        cout<<"Christmas Eve Eve";
    }else{
        cout<<"Christmas Eve Eve Eve";
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
lst = [list(map(int, input().split())) for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        for l in lst:
            if l[2] != 0:
                H = abs(cx-l[0]) + abs(cy-l[1]) + l[2]
        for l in lst:
            if l[2] != max(0, H - abs(cx-l[0]) - abs(cy-l[1])):
                break
        else:
            print(cx, cy, H)
            exit(0)


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

int main() {
  int n,k,r,s,p;
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  long long kotae=0;
  for(int i=0;i<n;i++){
    if(i+k<n){
      if(t[i]==t[i+k]){
        t[i+k]='a';
      }
    }
    if(t[i]=='r')kotae+=p;
    else if(t[i]=='s')kotae+=r;
    else if(t[i]=='p')kotae+=s;
  }
  cout<<kotae<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL << 25) // 33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void) {
  int n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << endl;
    return 0;
  }
  if(n == 2) {
    cout << "Yes" << endl;
    cout << 1 << endl << 2 << endl << 3 << endl;
    return 0;
  }

  VI v, ans;
  if (x == 2) {
    REP(i, 2 * n - 1) {
      if(i+1 != 1 && i+1 != 2 && i+1 != 3 && i+1 != 4) v.push_back(i + 1);
    }
    REP(i, n - 2) ans.push_back(v[i]);
    ans.push_back(3);
    ans.push_back(2);
    ans.push_back(1);
    ans.push_back(4);
    FOR(i, n + 2, 2 * n - 1) ans.push_back(v[i-4]);
  } else {
    REP(i, 2 * n - 1) {
      if(i+1 != x-2 && i+1 != x-1 && i+1 != x && i+1 != x+1) v.push_back(i + 1);
    }
    //for(int i=0; i<v.size(); ++i) cout << v[i] << " "; cout << endl;
    REP(i, n - 2) ans.push_back(v[i]);
    ans.push_back(x - 1);
    ans.push_back(x);
    ans.push_back(x + 1);
    ans.push_back(x - 2);
    FOR(i, n + 2, 2 * n - 1) ans.push_back(v[i-4]);
  }

  cout << "Yes" << endl;
  //cout << ans.size() << endl;
  for (int i : ans)
    cout << i << endl;

  return 0;
}


Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 文字列の入力
		if (a == b && b != c) {
		    System.out.println("Yes");
        } else if (a == c && b != c) {
            System.out.println("Yes");
        } else if (b == c && a != c) {
            System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;
int main(void)
{
	int n,k;
	char c;
	bool flag=false;
	string str,s;
	map<string,int> words;
	map<string,int>::iterator it;
	deque<int> choice;
	while(1){
		cin >> n;
		cin.ignore();
		if(n==0) break;
		for(int i=0;i<n;i++){
			getline(cin,str);
			str+=' ';
			while(!str.empty()){
				for(k=0;str[k]!=' '&&str[k]!='\0';k++);
				s=str.substr(0,k);
				str=str.substr(k+1);
				words[s]++;
			}
		}
		cin >> c;
		for(it=words.begin();it!=words.end();++it){
			if((*it).first[0]==c) choice.push_back((*it).second);
		}
		if(choice.empty()) cout << "NA";
		else{
			sort(choice.begin(),choice.end());
			for(int i=0;i<5&&i<choice.size();i++){
				for(it=words.begin();it!=words.end();++it){
					if(choice[choice.size()-1-i]==(*it).second&&(*it).first[0]==c){
						if(flag==true) cout << " ";
						else flag=true;
						cout << (*it).first;
						words.erase(it);
						break;
					}
				}
			}
		}
		cout << endl;
		flag=false;
		words.clear();
		choice.clear();
	}
	return 0;
}

Measured memory_bytes: 1232
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, x;
  cin >> n >> x;
  int d = 0;
  for (int i = 1; i <= n; i++) {
    int l; cin >> l;
    d += l;
    if (d > x) {
      cout << i << '\n';
      return;
    }
  }
  cout << n + 1 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 +7;
const ll MAXN = 1e6 + 5;

ll n,k;
ll a[MAXN];

ll check(ll x){
	ll res=0;
	for(int i=0;i<n;i++){
		if(a[i]<0){
			ll L=i,R=n;
			while(R-L>1){
				ll mid=L+R>>1;
				if(a[i]*a[mid]<=x){
					R=mid;
				}else{
					L=mid;
				}
			}
			res+=n-R;
		}else{
			ll L=i,R=n;
			while(R-L>1){
				ll mid=L+R>>1;
				if(a[i]*a[mid]<=x){
					L=mid;
				}else{
					R=mid;
				}
			}
			res+=L-i;
		}
	}
	return res;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll L=-1e18,R=1e18;
	while(R-L>1){
		ll Mid=L+R>>1;
		if(check(Mid)<k){
			L=Mid;
		}else{
			R=Mid;
		}
	}
	cout<<R;
	return 0;
}


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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto C = Combination_mod(N);
    long H(long n, long r)
    {
        return C(n + r - 1, r);
    }

    // writeln(C(5, 0));
    foreach (x; 1 .. K + 1)
    {
        long a = C(N - K + 1, x) * H(x, K - x) % MOD;
        writeln(a);
    }

}

/// Number of k-combinations % m (precalculated)
alias Combination_mod = Combination_modImpl!long;
struct Combination_modImpl(T)
{
    T _n, _m;
    T[] _fact, _factinv;
    this(T maxnum, T mod = 10 ^^ 9 + 7)
    {
        _n = maxnum, _m = mod, _fact = new T[](_n + 1), _factinv = new T[](_n + 1), _fact[0] = 1;
        foreach (i; 1 .. _n + 1)
            _fact[i] = _fact[i - 1] * i % _m;
        T powmod(T x, T n, T m)
        {
            if (n < 1)
                return 1;
            if (n & 1)
            {
                return x * powmod(x, n - 1, m) % m;
            }
            T tmp = powmod(x, n / 2, m);
            return tmp * tmp % m;
        }

        foreach (i; 0 .. _n + 1)
            _factinv[i] = powmod(_fact[i], _m - 2, _m);
    }

    T opCall(T n, T k, T dummy = 10 ^^ 9 + 7)
    {
        return n < k ? 0 : ((_fact[n] * _factinv[n - k] % _m) * _factinv[k] % _m);
    }
}


Measured memory_bytes: 332
import java.util.*;

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

        int c11 = sc.nextInt();
        int c12 = sc.nextInt();
        int c13 = sc.nextInt();
        int c21 = sc.nextInt();
        int c22 = sc.nextInt();
        int c23 = sc.nextInt();
        int c31 = sc.nextInt();
        int c32 = sc.nextInt();
        int c33 = sc.nextInt();
        
        for (int a1=0; a1<201; a1++) {
            int b1 = c11 - a1;
            int b2 = c12 - a1;
            int b3 = c13 - a1;
            int a2 = c23 - b3;
            int a3 = c33 - b3;

            if (a2 + b1 == c21 && a2 + b2 == c22 && a2 + b3 == c23 &&
                    a3 + b1 == c31 && a3 + b2 == c32 && a3 + b3 == c33) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
        return;
    }
}



Measured memory_bytes: 22864
#include <stdio.h>
void sort(int *a, int *b)
{
    int temp;
    if(*b>*a) {
        temp = *a;
        *a = *b;
        *b = temp;  
    }
}
int main(void)
{
    int r,g,b,n;
    scanf("%d %d %d %d",&r,&g,&b,&n);
    int first,second,third;
    if(r > g && r > b)  {
        first = r;
        if(g>b) {
            second = g;
            third = b;
        }
        else {
            second = b;
            third = g;
        }
    }

    else
    {
        if(g > b)   {
            first = g;
            if(r>b) {
                second = r;
                third = b;
            }
            else {
                second = b;
                third = r;
            }
        }
        else {
            first = b;
            if(r>g) {
                second = r;
                third = g;
            }
            else {
                second = g;
                third = r;
            }
        }
    }
    int ans,i,j;
    ans = 0;
    for(i = 0; i <= n/first; i ++) {  //i indicates the number of the balls in the box whose capacity is the bigeest//
        for (j = 0; j <= (n-i*first)/second; j ++)   {
            if((n-i*first-j*second) % third == 0)    {
                ans++;
            }
        }
    }
    printf("%d",ans);
}

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

int main(){
  int N=0, K=0, counter=0;
  string N_origin="", N_reversed="";
  cin >> N >> K;
  
  for(N; N<=K; N++){
    N_reversed = to_string(N);
    N_origin = N_reversed;
    reverse(N_reversed.begin(), N_reversed.end());
    if(N_origin == N_reversed)
      counter++;
  }
  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
int min(int x,int y){
	if(x > y){
		return y;
	}
	return x;
}
using namespace std;
int main(void){
	int n=0;
	cin>>n;
	long long int copy[300][300];
	long long int root[300][300];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>root[i][j];
			copy[i][j]=root[i][j];
		}
	}
	long long int ans=0;
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(j>=i)break;
				if(i==k || j==k)continue;
				int may=root[i][k]+root[k][j];
				if(may < root[i][j]){
					cout<<-1<<endl;
					return 0;
				}
				if(may == copy[i][j]){
					copy[i][j]=0;
				}		
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j>=i)break;
			ans+=copy[i][j];
		}
	}
	if(ans==0){
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n, a[200010], wa[200010];

int main(void){
    cin >> n;
    for(int i=0;i<n;++i) cin >> a[i];
    long long sum = 0;
    for(int i=0;i<n;++i){
        sum += a[i];
        wa[i+1] = sum;
    }
    long long X=0, ans=0;
    sum = 0;
    int r = 0;
    for(int l=0;l<n;++l){
        while(r < n && ((sum + a[r]) <= (X ^ a[r]))){
            sum += a[r];
            X ^= a[r];
            ++r;
        }
        ans += r-l;
        if(r==l) ++r;
        else{
            sum -= a[l];
            X ^= a[l];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")

var one = Int(split[0])!
var zero = Int(split[1])!
var minus = Int(split[2])!
var count = Int(split[3])!

var max = 0

var flag = true

while flag {
    
    if count >= one {
        max = one
        count -= one
    } else {
        max = count
        count = 0
    }
    
    if count == 0 {
        flag = false
        break
    }

    if count >= zero {
        count -= zero
    } else {
        count = 0
    }

    if count == 0 {
        flag = false
        break
    }
    
    if count >= minus {
        max += -1*minus
        count -= minus
    } else {
        max -= count
        count = 0
    }
    
    if count == 0 {
        flag = false
        break
    }
}

print(max)

Measured memory_bytes: 14176
s = input()

ch = 0
x = 1

rem = [0] * 2019
ans = 0
rem[0] = 1

for c in reversed(s):
    ch = (ch + int(c) * x) % 2019
    x = (x * 10) % 2019
    rem[ch] = rem[ch] + 1

print(sum(v * (v - 1)//2 for v in rem))



Measured memory_bytes: 68344
object Main extends App {

  import scala.io.StdIn._

  val memo = Array.tabulate(100000){_ ⇒ false}
  var s = readLine.trim.toInt
  var count = 1
  while (!memo(s)){
    count += 1
    memo(s) = true
    s = if (s % 2 == 0) s / 2 else 3 * s + 1
  }
  println(count)

  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 27808
/**
*    created: 25.07.2020 13:44:27
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8]={0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8]={1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n; cin >> n;
    vector<int> x(n), y(n), h(n);
    rep(i,n) cin >> x[i] >> y[i] >> h[i];
    int mx = 101;
    rep(yco,mx) rep(xco,mx) {
        int tmph = -1;
        rep(i,n) {
            if (h[i] > 0) {
                int tmp = h[i] + abs(yco-y[i]) + abs(xco-x[i]);
                if (tmph == -1) tmph = tmp;
                else {
                    if (tmph != tmp) {
                        tmph = -2;
                        break;
                    }
                }
            }
        }
        if (tmph == -2) continue;
        rep(i,n) {
            if (h[i] == 0) {
                int dis = abs(yco-y[i]) + abs(xco-x[i]);
                if (tmph > dis) {
                    tmph = -2;
                    break;
                }
            }
        }
        if (tmph == -2) continue;
        cout << xco << " " << yco << " " << tmph << endl;
    }
    return 0;
}

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

int main() {
  int K;
  cin >> K;
  
  int even = 0;
  
  int i = 1;
  while (i <= K) {
    if (i % 2 == 0) {
      even++;
    }
    i++;
  }
  
  cout << (K - even) * even << endl;
}

Measured memory_bytes: 256