akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

bool solve() {
  // Inputs
  int n, m;
  cin >> n >> m;
  if (n == 0 && m == 0) {
    return false;
  }
  vector<int> a(n), b(n);
  for (int &i : a) {
    cin >> i;
  }
  for (int &i : b) {
    cin >> i;
  }

  // Calculate the minimum number of button presses for each counter
  vector<int> c(n);
  for (int i = 0; i < n; ++i) {
    c[i] = b[i] - a[i];
    if (c[i] < 0) {
      c[i] += m;
    }
  }

  // dp[i][j] := the minimum number of button presses to display target values
  //             for 0-th to i-th counters when the i-th button is pressed
  //             c[i]+j*m times.
  vector<vector<int>> dp(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    dp[0][i] = c[0] + i * m;
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (c[i - 1] <= c[i]) {
        dp[i][j] = dp[i - 1][j] + (c[i] - c[i - 1]);
        if (j < n - 1) {
          dp[i][j] = min(dp[i][j], dp[i - 1][j + 1]);
        }
      } else {
        dp[i][j] = dp[i - 1][j];
        if (j > 0) {
          dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (c[i] - c[i - 1] + m));
        }
      }
    }
  }

  // Output the minimum number of button presses to display target values for
  // all counters.
  cout << *min_element(dp.back().begin(), dp.back().end()) << endl;

  return true;
}

int main() {
  while (solve()) {
  }
}


Measured memory_bytes: 6804
object Main {
  import java.util.Scanner

  implicit class RichScanner(sc: Scanner) {
    def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }
    def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }
    def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }
    def readLineStrings: Array[String] = sc.nextLine().split(' ')
    def readLineInts: Array[Int] = readLineStrings.map(_.toInt)
    def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)
  }

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def sumProbOfWinning(n: Int, k: Int): Double = {
    if (k == 1) return 0

    val nextBoundary = (k + 1) / 2

    val winIfSuccessfulRange = {
      if (n * 2 < k) 0
      else Math.min(n + 1, k) - nextBoundary
    }

    winIfSuccessfulRange / 2.0 + sumProbOfWinning(n, nextBoundary) / 2.0
  }

  def solve(sc: Scanner): Unit = {
    val Array(n, k) = sc.readLineInts

    val sum = if (n >= k) {
      (n - k + 1) + sumProbOfWinning(k - 1, k)
    } else {
      sumProbOfWinning(n, k)
    }

    println(sum / n)
  }
}


Measured memory_bytes: 25788
#include <iostream>

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (1) {
		int x, y;
		int s;
		cin >> x >> y >> s;
		if (x == 0) break;
		
		int maxvalue = 0;
		FOR(i, 1, s) {
			FOR(j, 1, s) {
				int value1 = i, value2 = j;
//				cout << value1 << " " << value2 << endl;
				int beforesumvalue = (value1 * (100 + x) / 100) + (value2 * (100 + x) / 100);
//				cout << beforesumvalue << endl;
				if (beforesumvalue == s) {
					int aftersumvalue = (value1 * (100 + y) / 100) + (value2 * (100 + y) / 100);
//					cout << aftersumvalue << endl;
					maxvalue = max(maxvalue, aftersumvalue);
				}
			}
		}
		
		cout << maxvalue << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 10005
#define P pair<int,int>
using namespace std;
int main()
{
	
	int h, a;
	cin >> h >> a;
	ll b[200005];
	for(int i=0;i<h;i++)
	cin>>b[i];
	sort(b,b+h);
	ll ans=0;
	for(int i=0;i<h-a;i++)
	ans+=b[i];
	cout<<ans<<endl;
}



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

int main(){
	int n;
	int x;

	std::cin >> n;
	std::cin >> x;

	std::vector<int> m(n);
	for(int i = 0; i < n; ++i){
		std::cin >> m.at(i);
	}

	//make all kind of doughnut, one each
	for(int i = 0; i < n; ++i){
		x -= m.at(i);
	}

	//search minimum of m_i, then make doughnut_i as many as possible
	int cand;
	int candi;

	for(int i = 0; i < n; ++i){
		if(m.at(i) < cand || i == 0){
			cand = m.at(i);
			candi = i;
		}
	}

	std::cout << n + x/m.at(candi) << std::endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = scan.next();
		TreeSet<Integer> ts = new TreeSet<>();
		int x = 0;
		ts.add(x);
		for (int i = 0; i < n; i++) {
			if (s.charAt(i) == 'I') {
				ts.add(++x);
			} else if (s.charAt(i) == 'D') {
				ts.add(--x);
			}
		}
		System.out.println(ts.last());

	}
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys


def solve(N: int):
    ans = 0
    for n in range(1, N+1):
        count = 0
        if n % 2 == 0:
            pass
        else:
            for i in range(1, n+1):
                if n % i == 0:
                    count += 1
            if count == 8:
                ans += 1
    print(int(ans))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const char t[] = "keyence";

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int n, m, pre, suf;
char s[105];

int main(){
	scanf("%s", s), n = strlen(s), m = strlen(t);
	for(pre = 0; pre < n && s[pre] == t[pre]; pre++);
	for(suf = 0; suf < n && s[n - suf - 1] == t[m - suf - 1]; suf++);
	return puts(pre + suf >= m ? "YES" : "NO"), 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int d,g;cin>>d>>g;g/=100;
  int p[10],c[10];
  rep(i,d){
    cin>>p[i]>>c[i];c[i]/=100;
  }
  int ans = INF;
  rep(i,(1<<d)){
    int count = 0,
        score = 0;
    int headp = -1;
    rep(j,d){
      if(i&(1<<j)){
        count += p[j];
        score += c[j];
        score += p[j] * (j+1);
      }else{
        headp = j;
      }
    }
    int additionalCount = 0;
    while(score<g&&additionalCount<p[headp]){
      additionalCount++;score+=(headp+1);
    }
    count += additionalCount;
    if(score>=g)ans = min(ans,count);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define pli pair<long long,int>
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back

const int maxn=1e6+10;
const int maxt=2e5+10;
const long long inf=1e16;
const int mod=1e9;

using namespace std;

string s;
int a,b,c;

inline void init(){
    cin>>s;
}

inline void prepare(){
    for(int i=0;i<3;i++){
        if(s[i]=='a') a++;
        if(s[i]=='b') b++;
        if(s[i]=='c') c++;
    }
}

inline void solve(){
    if(a==1&&b==1&&c==1) cout<<"Yes";
    else cout<<"No";
}

inline void file(){
    #define task "TEST"
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    freopen(task".INP","r",stdin);
    freopen(task".OUT","w",stdout);
}

int main(){
    //file();
    init();
    prepare();
    //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int d[10][10];

int main() {
    int n,m;
    cin>>n>>m;
    
    rep(i,10){
        rep(j,10){
            int c;
            cin>>c;
            d[i][j]=c;
        }
    }
    rep(k,10){
        rep(i,10){
            rep(j,10){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

    ll ans=0;
    rep(i,n){
        rep(j,m){
            int a;
            cin>>a;
            if(a==-1) continue;
            ans+=d[a][1];
        }
    }

    cout<<ans<<endl;
}


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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        String S;
        S = sc.next();

        final Solver solver = new Solver();
        solver.solve(N, S);
    }
}

class Solver {
    public void solve(long N, String S) {
        int ans = 1;
        char current = S.charAt(0);
        for (int i = 1; i < N; i++) {
            if (current != S.charAt(i)) {
                ans++;
                current = S.charAt(i);
            }
        }
        System.out.println(ans);
    }
}



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

using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

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

  int a, b;
  cin >> a >> b;

  int tap=0;
  int sasikomi=1;

  while(sasikomi<b){
    tap++;
    sasikomi+=a-1;
  }

  cout << tap;

    return 0;
}

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

int main ()
{
	int n,i,j,k,mod2=0,mod4=0,gg=0;
	int a[100005];
	cin>>n;
	for(i=0; i<n; i++)
	{
		cin>>a[i];
		if(a[i]%4==0)
			mod4++;
		else if(a[i]%2==0)
			mod2++;
		else
			gg++;
	}
	if(mod4>=gg)
		cout<<"Yes"<<endl;
	else //mod4 < gg
	{
		if(mod2 == 0)
		{
			if(mod4+1>=gg)
				cout<<"Yes";
			else
				cout<<"No";
		}
		else// mod4<gg && mod2!=0
		{
			//if( 2 * mod4 + mod2 >= n )
			if(mod4 >= gg)
				cout<<"Yes";
			else
				cout<<"No";
		}
	}

	return 0;
}
/*分类讨论下。
显然，任意数和 4 的倍数相乘，其结果仍是 4 的倍数；
显然，若存在任意数量 2 的倍数，两两之间乘起来就是 4 的倍数；
如果存在一个数既不是 4 的倍数，也不是 2 的倍数（即因子里没有 2 ）：
放在 2 的倍数旁边，一定不符合要求；
放在 4 的倍数旁边，两两相乘一定是 4 的倍数。
因此符合要求的排列一定是，所有 2 的倍数相邻排在一起，
所有 4 的倍数和剩下的数相间排列，这
些剩下的元素个数不能超过 4 的倍数的数量，不
然所有 4 的倍数都被包起来了。*/



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

int main(){
    int N;string s;
    cin >> N >> s;
    LL ans = 1;
    char c;
    c = s[0];
    for(int i = 0;i < N-1;i++){
        if(s[i] != s[i+1])  ans++;
    }
    cout << ans << endl;
}

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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define all(x) (x).begin() , (x).end()

ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}

int fac(int n)
{
	if (n == 0 || n == 1)
		return 1;
	return n * fac(n - 1);
}

int findSmaller(int a[] , int l , int r) {

	int cnt = 0 , i;
	for (i = l + 1 ; i <= r ; i++)
		if (a[i] < a[l])
			++cnt;
	return cnt;
}

int find(int a[],  int n)
{
	int mul = fac(n);
	int rank = 1;
	int cntR;

	int i;

	for (i = 0 ; i < n ; i++) {
		mul /= n - i;

		cntR = findSmaller(a , i , n - 1);

		rank += cntR * mul;
	}

	return rank;
}

void solve()
{
	int n;
	cin >> n;

	int p[n] , q[n];
	rep(i , 0 , n)
	cin >> p[i];

	rep(i , 0, n )
	cin >> q[i];

	int a = find(p , n) , b = find(q , n);

	cout << abs(a - b) << "\n";
}

int main() {

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

	int t = 1;
	//cin >> t;
	while (t--)
		solve();

	return 0;
}





Measured memory_bytes: 3652
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int c = 0;
		
		for (int i=0; i<N; i++) {
			if (sc.nextInt() == c+1) {
				c++;
			}
		}
		System.out.println(c==0 ? -1 : N-c);
	}
}

Measured memory_bytes: 64864
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define oo (int)1e7
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e2 + 5, M = 1e5 + 5;

int main(){
    int x;
    cin >> x;
    cout << x * x << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#define int long long int
#define rep(i,a,b) for(int i=(a);i<(b);++i)

#define vec vector

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

using namespace std;


signed main()
{
  int N; cin >> N;
  string s; cin >> s;
  vec<bool> S(N);
  rep(i, 0, N) {
    S[i] = (s[i] == 'o') ? 0 : 1;
  }

  vec<bool> ans(N+1);
  rep(i, 0, 2) {
    rep(j, 0, 2) {
      ans[0] = i; ans[1] = j;
      rep(k, 1, N) {
        ans[k+1] = ans[k] ^ ans[k-1] ^ S[k];
      }
      if (ans[0] == ans[N] && (ans[N-1] ^ ans[0] ^ ans[1]) == S[0]) {
        rep(i, 0, N) {
          cout << ((ans[i] == 0) ? 'S' : 'W');
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
n, k = gets.chomp.split(" ").map(&:to_i)
a = []
n.times do
  a << gets.chomp.to_i
end

a.sort!

ret = a[n-1] - a[0]
(0..(n-k)).each do |i|
  x = a[i+k-1] - a[i] 
  if  x < ret
    ret = x
  end
end

puts ret

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define MP make_pair
#define ull unsigned long long int
#define F first
#define S second
#define put insert
#define pb push_back
#define rsort(arr) sort(arr.begin(),arr.end(),greater<int>())
#define srt(arr) sort(arr.begin(),arr.end())
#define arrInput(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define rev(arr) reverse(arr.begin(), arr.end())
ll MOD = 1e9+7;
int main() {
    fastio
    // int t;
    // cin>>t;
    // while(t--) {
    string s;
    cin>>s;
    int c = count(s.begin(), s.end(), 'R');
    if(c == 3)
        cout<<3;
    else if(c == 2) {
        if(s[1] == 'S')
            cout<<1;
        else
            cout<<2;
    } else if(c == 1)
        cout<<1;
    else
        cout<<0;
    // }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 200050;
LL n,k,z[N],mz,f[N],mf,mze;
bool check(LL x){
	LL sum = 0;
	if (x == 0){
		sum += mz * mf;
		sum += mze * (mz + mf);
		sum += mze * (mze - 1) / 2; 
		return sum <= k;
	}
	if (x < 0){
		x = abs(x);
		LL v;
		for (int i = 1; i <= mf; ++i){
			v = x / f[i];
			while (f[i]*(v-1)>=x) --v;
			while (f[i] * v < x) ++v;
			sum += mz + 1 - (lower_bound(z+1,z+mz+1,v) - z);
		}
		return sum <= k;
	}
	sum += mz * mf;
	sum += mze * (mz + mf);
	sum += mze * (mze - 1) / 2;
	LL v,sum2 = 0;
	for (int i = 1; i <= mf; ++i) if (f[i] * f[i] <= x) --sum2;
	for (int i = 1; i <= mz; ++i) if (z[i] * z[i] <= x) --sum2;
	for (int i = 1; i <= mf; ++i){
		v = x / f[i];
		while (f[i]*(v+1)<=x) ++v;
		while (f[i] * v > x) --v;
		sum2 += upper_bound(f+1,f+mf+1,v) - f - 1;
	}
	for (int i = 1; i <= mz; ++i){
		v = x / z[i];
		while (z[i]*(v+1)<=x) ++v;
		while (z[i] * v > x) --v;
		sum2 += upper_bound(z+1,z+mz+1,v) - z - 1;
	}
	sum += sum2/2;
	return sum <= k;
}
int main(){
	LL L,R,Mid,Ans;
	read(n); read(k); --k; //k = (n*(n-1)/2-k)
	while (n--){ read(L); if (L<0) f[++mf] = -L; else if (L>0) z[++mz] = L; else ++mze; }
	sort(z+1,z+mz+1); sort(f+1,f+mf+1);
	L = -1 * (1000000000ll) * 1000000000ll; R = L * -1; Ans = R+1;
	while (L<=R){
		Mid = L+R>>1;
		if (check(Mid)) L = Mid+1; else Ans = Mid,R = Mid - 1;
	} 
	cout<<Ans<<endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int max_num = 123456 * 2;
    vector<bool> isPrime(max_num+1, true);
    isPrime[0] = isPrime[1] = false;

    for(int i=2; i*i <= max_num; i++) {
        if (!isPrime[i]) continue;
        for(int j=i*2; j <= max_num; j+=i) {
            isPrime[j] = false;
        }
    }

    while (true) {
        int n; cin >> n;
        if (!n) break;

        int left=0, right=0;
        rep(i, n*2+1) {
            if (isPrime[i]) {
                if (i<=n) {left++; right++;}
                else right++;
            }
        }

        cout << right - left << endl;
    }
    
}


Measured memory_bytes: 3268
#include <stdio.h>

int main(){
    int x, a, b, c, count = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(x = a; x <= b; x++){
        if(c % x == 0){
            count++;
        }
    }
    
    printf("%d\n",count);
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

//約数列挙アルゴリズム　O（√N）
vector <ll > divisor(ll n) {
  vector <ll> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

//累乗を高速に（MODとってないよ！！！！！！）
ll my_pow(ll a,ll b){
  ll res;
  if(b==1) return a;
  if(b % 2 == 0){
    res = my_pow(a,b/2);
    return res * res;
  } else {
    res = my_pow(a,b/2);
    return res * res * a;
  }
}

ll check(ll a,ll b,ll x,ll d){
  ll t = my_pow(a,4) + my_pow(a,3)*b + my_pow(a,2)*my_pow(b,2)+ my_pow(b,4) + my_pow(b,3)*a;
  return (t*d == x);
}





int main(){
  ll X; cin>>X;
  vector <ll> divs = divisor(X);
  reverse(all(divs));

  for(int i=0;i<divs.size();i++){
    ll d = divs[i];
    for(int B = -5000;B<=5000;B++){
     // ll Y = my_pow(B + d,5) - my_pow(B,5);
     // cout<<Y<<endl;
      if(check(B+d,B,X,d)){
        cout<<d+B<<" "<<B<<endl;
        return 0;
      }
    }
    d = -d;

        for(int B = -5000;B<=5000;B++){
     // ll Y = my_pow(B + d,5) - my_pow(B,5);
     // cout<<Y<<endl;
      if(check(B+d,B,X,d)){
        cout<<d+B<<" "<<B<<endl;
        return 0;
      }
    }
   

     // cout<<B<<endl;
    }

    assert(5==9);

    cout<<"NOT FOUND"<<endl;

    return 0;

  }
 




Measured memory_bytes: 3628
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String T = in.next();

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < T.length(); i++)
            ans.append(T.charAt(i) == 'P' ? "P" : "D");
        out.println(ans);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 37528
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
int h, w, n, m, s, ans = 0, a[10000], num = 0, sum = 0;
int flag = 0;
string str,stt;
int main() {
	cin >>str;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'C')
			flag = 1;
		if (flag == 1 && str[i] == 'F') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout <<"No"<< endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INF 0x3f3f3f3f
#define nmax 200
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
char str[nmax];
int main()
{
    //freopen("in.txt","r",stdin);
    for(int i = 0; i<3; ++i){
        scanf("%s",str);
        printf("%c",str[0]-32);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	char *p=(char*)S.c_str();
	while (*p!='\0'){
		if (!memcmp(p,"dreameraser",11)){
			p+=11;
			continue;
		}else if (!memcmp(p,"dreamerase",10)){
			p+=10;
			continue;
		}else if (!memcmp(p,"dreamer",7)){
			p+=7;
			continue;
		}else if (!memcmp(p,"eraser",6)){
			p+=6;
			continue;
		}else if (!memcmp(p,"dream",5)){
			p+=5;
			continue;
		}else if (!memcmp(p,"erase",5)){
			p+=5;
			continue;
		}
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////
void solve(){
  inl(N,M);
  if(N >= M / 2) die(M / 2);
  else die((N * 2 + M) / 4);
}



Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int H, W;
    cin >> H >> W;

    vs a(H);
    rep(i, H) cin >> a[i];

    vvll dp(H + 1, vll(W + 1));

    dp[1][0] = 1;

    reple(h, 1, H)
    {
        reple(w, 1, W)
        {
            if (a[h - 1][w - 1] == '.')
            {
                dp[h][w] = dp[h - 1][w] + dp[h][w - 1];
                dp[h][w] %= MOD;
            }
        }
    }

    cout << dp[H][W] << endl;

    return 0;
}

Measured memory_bytes: 9216
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
 

var a = parseInt(lines[0].split(' ')[0],10);
var b = parseInt(lines[1].split(' ')[0],10);

if(a===b){
    console.log(0);
}else{
    console.log(1);
}

});

Measured memory_bytes: 7628
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float('inf')
from functools import reduce

n,m = map(int,input().split())
edge=[]
for i in range(m):
    a, b, c = map(int, input().split())
    edge.append([a-1,b-1,-c])

dist = [inf]*n
dist[0] = 0
for i in range(1,n):
    for j in range(m):
        if dist[edge[j][1]] > dist[edge[j][0]]+edge[j][2]:
            dist[edge[j][1]] = dist[edge[j][0]]+edge[j][2]

ans = dist[n-1]

for j in range(m):
    if dist[edge[j][1]] > dist[edge[j][0]]+edge[j][2]:
        dist[edge[j][1]] = dist[edge[j][0]]+edge[j][2]
if dist[n-1]<ans:
    print("inf")
else:
    print(-ans)

Measured memory_bytes: 45928
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, M, MM; cin >> N >> M;
  string str;
  vector<pair<ll, char>> qr(M);
  REP(i, M) {
    cin >> qr[i].first >> qr[i].second;
    qr[i].first--;
  }
  if (M == 0) {
    if (N == 1) { 
      cout << 0 << endl;
    }
    if (N == 2) { 
      cout << 10 << endl;
    }
    if (N == 3) { 
      cout << 100 << endl;
    }
    return 0;
  }
  REP(j, 1000) {
    str = to_string(j);
    bool ok = true;
    REP(i, M) {
      if (str.length() == N && str.length() > qr[i].first) {
        ok = ok && str[qr[i].first] == qr[i].second;
      } else {
        ok = false;
      }
    }
    if (ok) {
      cout << j << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

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

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

int main(){
  ll n,m;
  cin >> n >> m;

  string s,t;
  cin >> s >> t;

  ll ans = lcm(n,m);
  ll s_step=ans/n, t_step=ans/m;

  ll j = min(n,m);
  rep(i,j){
    if(t_step*i>=n||s_step*i>=m) break;
    if(s.at(t_step*i)!=t.at(s_step*i)) ans = -1;
  }
  
  cout << ans;
}

Measured memory_bytes: 3732
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL N, M;
	cin >> N >> M;
	vector<bool> is1(N+1, false);
	vector<bool> isN(N + 1, false);

	bool flag = false;

	REP(i, M) {
		LL a, b;
		cin >> a >> b;
		if (a == 1 && b == N) {
			flag = true;
		}

		if (a == N && b == 1) {
			flag = true;
		}


		if (a == 1) {
			is1[b] = true;
		}

		if (a == N) {
			isN[b] = true;
		}
		if (b == 1) {
			is1[a] = true;
		}

		if (b == N) {
			isN[a] = true;
		}
	}

	REP(i, N + 1) {
		if (is1[i] && isN[i]) {
			flag = true;
		}
	}

	if (flag) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>

int main()
{
	int n, k, m=0;
	std::cin >> n >> k;
	std::vector<int> a(n);
	for (int i = 0; i < k; i++) {
		int d, dd;
		std::cin >> d;
		for (int j = 0; j < d; j++) {
			std::cin >> dd;
			a[dd-1] = 1;
		}
	}
	for (int l = 0; l < n; l++) {
		if (a.at(l) == 1) {}
		else { m++; }
	}
	std::cout << m << std::endl;
	return 0;

}


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

def resolve():
    al=['A','B','C','D','E','F','G','H','I','J','K','L',\
        'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
    h,w=map(int, input().split())
    l=[list(input().split()) for i in range(h)]
    for j in range(h):
        for k in range(w):
            if l[j][k]=='snuke':
                print(al[k]+str(j+1))
resolve()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    int N;
    cin >> N;
    int B[100];
    int C[100];
    for(int i = 0; i < N; i++){
        cin >> B[i];
        B[i]--;
        C[i] = i - B[i];
    }
    stack<int>S;
    for(int i = 0; i < N; i++){
        int idx = -1;
        for(int j = 0; j < N; j++){
            if(C[j]==0)idx = j;
        }
        if(idx < 0){
            cout << -1 << endl;
            return 0;
        }
        S.push(B[idx] + 1);
        for(int j = idx; j < N; j++)C[j]--;
    }
    while(!S.empty()){
        int t = S.top();
        S.pop();
        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
ans = 0
for i in range(1,n):
    tmpans = 0
    streak = 0
    for j in range(n-i):
        if s[j] == s[j+i]:
            streak += 1
        else:
            tmpans = max(tmpans,min(i,streak))
            streak = 0
    tmpans = max(tmpans,min(i,streak))
    ans = max(tmpans,ans)
print(ans)


Measured memory_bytes: 42460
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v.at(i);
  }

  map<int, int> cnt[2];
  for (int i = 0; i < n; ++i) {
    cnt[i % 2][v[i]]++;
  }

  vector<pair<int, int>> pairs[2];
  for (int k = 0; k < 2; ++k) {
    cnt[k][0] = 0;
    for (auto p : cnt[k]) {
      pairs[k].push_back({p.second, p.first});
    }
    sort(pairs[k].rbegin(), pairs[k].rend());
  }

  int ans;
  if (pairs[0][0].second != pairs[1][0].second) {
    ans = n - pairs[0][0].first - pairs[1][0].first;
  } else {
    ans = n - max(pairs[0][1].first + pairs[1][0].first, pairs[0][0].first + pairs[1][1].first);
  }

  cout << ans << endl;
  
  // for (auto itr = cnt[0].begin(); itr != cnt[0].end(); ++itr) {
  //   cout << itr->first << " " << itr->second << endl;
  // }
  //
  // cout << endl;
  //
  // for (auto itr = cnt[1].begin(); itr != cnt[1].end(); ++itr) {
  //   cout << itr->first << " " << itr->second << endl;
  // }
  //
  // cout << "--" << endl;
  //
  // for (auto itr = pairs[0].begin(); itr != pairs[0].end(); ++ itr) {
  //   cout << itr->first << " " << itr -> second << endl;
  // }
  // cout << endl;
  //
  // for (auto itr = pairs[1].begin(); itr != pairs[1].end(); ++ itr) {
  //   cout << itr->first << " " << itr -> second << endl;
  // }
}

Measured memory_bytes: 6520
n, k = map(int, input().split())

if n % k == 0:
    ans = 0
    print(ans)
    exit()
else:
    n = n % k
    for i in range(10000000000000000000):
        res = abs(n - k)
        if n <= res:
            ans = n
            print(ans)
            exit()
        else:
            n = res


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int a,b,ans;
    cin>>a>>b;

    ans = a - 2*b;
    if(ans>0) cout << ans << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define ld long double
#define PI pair<ld,ll>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=500005;
int n,L,top;
PI q[N];
ll sum[N];
ld ans[N];
PI operator +(PI a,PI b){
	return mp((a.first*a.second+b.first*b.second)/(a.second+b.second),a.second+b.second);
}
signed main(){
	n=read(); L=read();
	for(int i=1;i<=n;i++){
		int t=read(),v=read();
		PI dq=mp(t,v);
		while(top&&q[top]>dq){if(q[top].second+dq.second>L)q[top].second=L-dq.second; dq=dq+q[top--]; }
		q[++top]=dq;
		sum[top]=sum[top-1]+dq.second;
		ans[top]=ans[top-1]+dq.first*dq.second;
		int pos=lower_bound(&sum[1],&sum[top+1],sum[top]-L)-sum;
		printf("%.7lf\n",(double)((ans[top]-ans[pos]+q[pos].first*(L-(sum[top]-sum[pos])))/L));
	}
	
}

Measured memory_bytes: 36352
#include<stdio.h>
#include<stdbool.h>
#define MAX 100000

bool flg;
int cnt=0;
int S[MAX],T[MAX];
int i,j,s,t;

int main(){
    scanf("%d",&s);
    for(i=0;i<s;i++){
        scanf("%d",&S[i]);
        //printf("%d ",S[i]);
    }
    //printf("\n");
    
    scanf("%d",&t);
    for(j=0;j<t;j++){
        scanf("%d",&T[j]);
        //printf("%d ",T[j]);
    }
    //printf("\n");
    
    
    for(j=0;j<t;j++){
        flg=false;
        for(i=0;i<s;i++){
            if(S[i]==T[j])flg=true;
        }
        if(flg)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}
 


Measured memory_bytes: 2048
//abc065_a.cpp
//Sun Sep 30 18:09:26 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int x,a,b;
	cin >> x >> a >> b;

	if (a-b >= 0){
		cout << "delicious" << endl;
	}else if (b-a <= x){
		cout << "safe" << endl;
	}else {
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 384
N, _M, X = gets.split.map(&:to_i)
array = Array.new(N+1) { 0 }
tolls = gets.split.map(&:to_i)
tolls.each do |toll|
  array[toll] = 1
end
score = []
score << array[0..X].inject(:+)
score << array[X..-1].inject(:+)
puts score.min


Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, M: int):
    print((M * 1900 + (N-M) * 100) * 2 ** M)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <stdio.h>

int main(void){
  int r,c,i,j;
  static int s[101][101];

  scanf("%d%d",&r,&c);

  for(i=0;i<=r;i++){
    for(j=0;j<c;j++){
      scanf("%d", &s[i][j]);
      printf("%d ", s[i][j]);
      s[i][c] += s[i][j];
      s[r][j] += s[i][j];
    }
    printf("%d\n",s[i][c]);
  }

  return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <bitset>

using namespace std;
int main(){
  // create 0000, 0001 in binary
  /// check flag and add + manipulator
  /// how? add substring _ string
  string S;
  cin >> S;
  int size = S.size();
  uint64_t sum = 0;
  for(int i=0;i<(1<<(size-1)); ++i) {
    string current{S[0]};
    uint64_t num = 0;
    //string formula = "";
    for(int j=1;j<size;++j) {
      string tmp{S[j]};
      if(i & (1<<(j-1))){
        //cout << "ok" << std::bitset<3>(i) << ":" << std::bitset<3>(1<<(j-1)) << endl; 
        //formula += current + "+";
        num += std::stoull(current);
        current = tmp;
      } else {
        //cout << "ng" << std::bitset<3>(i) << ":" << std::bitset<3>(1<<(j-1)) << endl; 
        current += tmp;
      }
    }
    //formula += current;
    num += std::stoull(current);
    sum += num;
    //cout << num << "/" << sum << "|" << formula << endl;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int sum = 0;
    int[] a = new int[n];
    int p = 0;
    String ans = "No";
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      sum += a[i];
    }
    for(int i = 0; i < n; i++) {
      if((a[i] * 4 * m) >= sum) p++;
    }
    if(p >= m) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int N,D,X;
    cin >> N >> D >> X;
    vector<int> a;
    LL ans=X;
    for(int i=0;i<N;i++){
        int t;
        cin >> t;
        for(int j=0;j<100;j++){
            if(t*j+1>D) break;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n, m, x;
  int a[m];

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

  int count = 0;
  for(int k=0;k<m;k++){
    if(a[k] < x){
      count++;
    }
  }

  if(count < m - count){
    cout << count << endl;
  }
  else{
    cout << (m - count)	<< endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>
#include <fstream>
#include <cstdlib>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

set<int> s;
int n;

void solve() {
	cin >> n;
	for (int i = 0, x; i < n; ++i) {
		cin >> x;
		if (s.find(x) != s.end()) {
			cout << "NO\n";
			exit(0);
		}
		s.insert(x);
	}
	cout << "YES\n";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // freopen("a_in", "r", stdin);
    // freopen("a_out", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 10112
//By Bibi
///                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
///             __.'              ~.   .~              `.__
///           .'//                  \./                  \`.
///        .'//                     |                     \`.
///       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \`.
///     .'//.-"                 `-.  |  .-'                 "-.\`.
///   .'//______.============-..   \ | /   ..-============.______\`.
/// .'______________________________\|/______________________________`.
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define dep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
int read(){
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int n,m;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	m=10-n%10;
	m+=10*(10-(n/10%10));
	m+=100*(10-(n/100%10));
	printf("%d\n",m );
	return 0;
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    save = -1
    for i in range(len(divisors)):
        if divisors[i] >= 200:
            save = i
            break
    if save > 0:
        divisors = divisors[:save]
    return divisors

def f(a, b):
  return a**5 - b**5

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -div-120
  b = -120
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -120
  b = -div-120
  while f(a, b) > X and b < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])

Measured memory_bytes: 9516
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  a*b%2 == 0 ? cout << "Even" << endl : cout << "Odd" << endl;
  return 0;
}

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

int main() {
  int N,gu=0; cin >> N;
  int A[N+10];
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i]%2==0) gu+=1;
  }
  cout << pow(3,N)-pow(2,gu) << endl;
}

Measured memory_bytes: 384