akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int num[200001];

bool comp(const P &a, const P &b){
  return a.second > b.second;
}

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    num[x]++;
  }
  vector<P> vec;
  for(int i = 0; i < 200001; i++){
    if(num[i] != 0)vec.pb(mk(i, num[i]));
  }
  sort(vec.begin(), vec.end(), comp);
  int all = 0;
  if(vec.size() < k){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < k; i++){
    all += vec[i].second;
  }
  cout << n - all << endl;
	return 0;
}


Measured memory_bytes: 3188
n,m=map(int,input().split())
h=input().split()
r=[]
for i in range(m):
 r.append([])
 r[i]=input().split()
a=[1]*n
for i in range(m):
 if int(h[int(r[i][0])-1])>int(h[int(r[i][1])-1]):
  a[int(r[i][1])-1]="0"
 elif int(h[int(r[i][0])-1])<int(h[int(r[i][1])-1]):
  a[int(r[i][0])-1]="0"
 elif int(h[int(r[i][0])-1])==int(h[int(r[i][1])-1]):
  a[int(r[i][0])-1]=a[int(r[i][1])-1]="0"
print(n-(a.count("0")))

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  if ( abs(x-a) > abs(x-b)) {
    cout << "B" << endl;
  }
  else { 
    cout << "A" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

int n;

int main () {
    cin >> n;
    vector<vector<int> >dp(n, vector<int>(3, -100)), a(n, vector<int>(3));
    for ( int i = 0; i < n; i++) {
        for ( int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    for ( int i = 0; i < 3; i++) {
        dp[0][i] = a[0][i];
    }
    for ( int i = 0; i < n - 1; i++) {
        for ( int j = 0; j < 3; j++) {
            for ( int z = 0; z < 3; z++) {
                if ( z == j ) {
                    continue;
                }
                dp[i + 1][z] = max(dp[i + 1][z], dp[i][j] + a[i + 1][z]);
            }
        }
    }
    cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);
}


Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.Petrozavodsk
{
    class VacantSeat
    {
        public static void Main()
        {
            var n = int.Parse(ReadLine().Trim());
            var left = 1; var right = n - 1;
            WriteLine(0);
            String first = ReadLine();
            String res = first;
            for (var i = 0; i < 19 && res != "Vacant"; ++i)
            {
                var mid = (left + right) / 2;
                WriteLine(mid);
                res = ReadLine().Trim();
                if (res != "Vacant")
                {
                    if ((mid % 2 == 0 && res == first) || (mid % 2 == 1 && res != first))
                        left = mid + 1;
                    else
                        right = mid - 1;
                }
            }
        }
    }
}


Measured memory_bytes: 13508
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();

		List<Integer> d = new ArrayList<>();
		for(int i = 0;i < l;i++) {
			d.add(sc.nextInt());
		}

		List<Integer> workD = new ArrayList<>(d);
		Collections.sort(workD, Collections.reverseOrder());
		int max = workD.get(0);
		int nextMax = workD.get(1);

		if(max == nextMax) {
			for(int i = 0;i < l;i++) {
				System.out.println(max);
			}
		}else {
			for(int i = 0;i < l;i++) {
				System.out.println(max == d.get(i) ? nextMax : max);
			}
		}
	}
}


Measured memory_bytes: 94620
using System;
public class Hello{
    public static void Main(){
        var s = int.Parse(Console.ReadLine());
        var command = Console.ReadLine().Split();
        int a = int.Parse(command[0]);
        int b = int.Parse(command[1]);
        var result = 0;
        
        for (var i = a; i <= b; i++){
            if(i % s == 0){
                Console.WriteLine("OK");
                result = 1;
                break;
            }
        }
        if(result != 1){
            Console.WriteLine("NG");
        }
    }
}


Measured memory_bytes: 27372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool hoge(int a){
    for(ll i=2;i*i <= a;i++){
        if(a%i == 0)return false;
    }
    return true;
}
int main(){
    int x;
    cin >> x;
    while(!hoge(x)){x++;}
    cout << x << endl;
}

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

// 大きいものから M 個
// x 以上の数が M 個以上あるような最大の x を求める
// 参考: ARC 037 C - 億マス計算
// https://atcoder.jp/contests/arc037/tasks/arc037_c

long long N, M;
vector<long long> A;

// x 以上の数が M 個以上あるかどうかを返す
bool func(int x) {
  long long cnt = 0;
  for (int i = 0; i < N; i++) {
    cnt += N - (lower_bound(A.begin(), A.end(), x - A.at(i)) - A.begin());
  }
  if (cnt >= M) return true;
  else return false;
}

int main() {
  cin >> N >> M;
  A.resize(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  // x 以上の数が M 個以上あるような最大の x を求める
  int left = 0;  // OK
  int right = 1000000007;  // NG
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (func(mid)) left = mid;
    else right = mid;
  }
  vector<long long> S(N+1);  // A の累積和
  for (int i = 0; i < N; i++) S.at(i+1) = S.at(i) + A.at(i);
  long long ans = 0;
  // M 個の和を求める
  for (int i = 0; i < N; i++) {
    // x 以上となる位置
    int idx = lower_bound(A.begin(), A.end(), left - A.at(i)) - A.begin();
    // x 以上の個数
    long long cnt = N - idx;
    ans += cnt * A.at(i) + (S.at(N) - S.at(idx));
    M -= cnt;
  }
  ans += M * left;  // M 個を超えているとき、超えた個数だけ x があるので引く
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=3*1e5+2;
int cnt[61][2];
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n;
      cin>>n;
      vector<pii> v[n];
      for(int i=0;i<n;i++)
      {
        int x;
        cin>>x;
        for(int j=0;j<x;j++)
        {
          int x,y;
          cin>>x>>y;
          x--;
          v[i].pb({x,y});
        }
      }
      int ans=0;
      for(int i=0;i<(1LL<<n);i++)
      {
        bool f=true;
        int cnt=0;
        for(int j=0;j<n;j++)
        {
          if(i&(1LL<<j))
          { 
            cnt++;
            for(auto x:v[j])
            {
              int lol=((i&(1LL<<x.fi))?1:0);
              if(lol!=x.se) f=false;
            }
          } 
          else{
            // for(auto x:v[j])
            // {
            //   int lol=((i&(1LL<<x.fi))?1:0);
            //   lol=1-lol;
            //   if(lol!=x.se) f=false;
            // }
          }  
        }
        if(f)
        {
          ans=max(ans,cnt);
        }
      }
      cout<<ans;
}
// I never lose. I either win or I learn

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC118 {
    class A {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadIntArray();
            WriteAnswer(a[1] % a[0] == 0 ? a[0] + a[1] : a[1] - a[0]);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(20);
    int n;
    cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    int ans = 0;
    forn(i, n) {
        forab(j, i + 1, n) {
            forab(k, j + 1, n) {
                if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
                    int s = a[i] + a[j] + a[k];
                    int m = max(a[i], max(a[j], a[k]));
                    if (m < s - m) ans++;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = pow(10, 9) + 7;
struct mint{ 
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod){} 

  mint operator-() const {return mint(-x);}

  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 {
    mint res(*this);
    return res -= a;
  }

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

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

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

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

mint f(int n){ 
  if(n == 0)return 1;
  mint x = f(n / 2); 
  x *= x; 
  if(n % 2 == 1)x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i = 0; i < a; ++i){
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n, a);
  ans -= choose(n, b);
  cout << ans.x << endl;
  return(0);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    StringBuilder sb = new StringBuilder();
    int l = N <= 4 ? 1 : N - 2;
    for (int i = 1; i <= M; i++) {
      sb.append(i).append(' ').append(i + l).append('\n');
      int m = l - 2;
      if (N % 2 == 0 && l >= N / 2 && m <= N / 2) m--;
      l = m;
    }
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 36048
N, M = map(int, input().split())
nmin = 1
nmax = N
for _ in range(M):
    l, r = map(int, input().split())
    nmin = max(nmin, l)
    nmax = min(nmax, r)
if nmin > nmax:
    print(0)
else:
    print(nmax - nmin + 1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
    cin>>n;
    if (n%2==1) {
        puts("0");
        return 0;
    }
    long long res=0;
    n/=2;
    while (n) {
        res+=n/5;
        n/=5;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
n =int(input())
AB = []
Sb = 0
for i in range(n):
    a, b = map(int, input().split())
    AB.append(a+b)
    Sb += b

AB.sort()
ans = 0
for i in range(n):
    if i%2 == 0:
        ans += AB.pop()
    else:
        AB.pop()
ans -= Sb
print(ans)


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

using namespace std;

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

  int x;
  cin >> x;

  int ans = 1;
  for (int i = 2; i < 32; ++i) {
    int a = i * i;
    while (a <= x) {
      ans = max(ans, a);
      a *= i;
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int n;
vi adj[100001];
int dp[100001][2];

int dfs(int cur,int par,int color){
    if(dp[cur][color]!=-1)return dp[cur][color];
    int ans=1;
    for(int ch:adj[cur]){
        if(ch!=par){
            if(color==0)ans=(ans*((dfs(ch,cur,1)+dfs(ch,cur,0)))%MOD)%MOD;
            else ans=(ans*dfs(ch,cur,0))%MOD;
        }
    }
    return dp[cur][color]=ans;
}

signed main(){
    FASTER;
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    cout<<(dfs(1,-1,0)+dfs(1,-1,1))%MOD;
}


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

int main(){
	int a, b, max;
	cin >> a >> b; 
	if(a > b){
		max = 2*a-1;
	}else if(a < b){
		max = 2*b-1;
	}else{
		max = a+b;
	}
	cout << max;
	return 0;
}

Measured memory_bytes: 256
N, Ma, Mb = map(int, input().split())
table = []
for i in range(N):
  a,b,c = map(int, input().split())
  table.append([a,b,c])
inf = 10**9
dp = [[[inf]*401 for i in range(401)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(1,N+1):
  a,b,c = table[i-1]
  for j in range(401):
    for k in range(401):
      dp[i][j][k] = dp[i-1][j][k]
      if 400>=j-a>=0 and 400>=k-b>=0:
        dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
ans = 10**9
i = 1
while max(Ma,Mb)*i <= 400:
  ans = min(ans,dp[N][Ma*i][Mb*i])
  i += 1
if ans == 10**9:
  ans = -1
print(ans)

Measured memory_bytes: 94300
n = int(input())
a = list(map(int, input().split(' ')))
a.append(-1)
lasti = -1
count = 0
result = 0
for i in a:
    if i == lasti:
        count += 1
    else:
        result += int((count + 1) / 2)
        count = 0
        lasti = i

print(result)


Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>

int main() {
  int N, T;
  scanf("%d %d", &N, &T);

  int res=0, last=0;
  for (int i=0; i<N; ++i) {
    int t;
    scanf("%d", &t);
    res += std::min(t-last, T);
    last = t;
  }

  printf("%d\n", res+T);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;
const ll N_MAX=100100;
vector<vector<ll>> G(N_MAX);
vector<ll> dp(N_MAX);
bool used[N_MAX];
vector<ll> ans;

void dfs(int u){
    if(used[u]) return;
    used[u]=true;
    for(auto e : G[u]){
        dfs(e);
    }
    ans.push_back(u);
}

void tsort(int v){
    for(int i=0;i<v;i++) dfs(i);
    reverse(ans.begin(),ans.end());
}

int main() {
    ll N,M;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        G[x].push_back(y);
    }

    tsort(N);
    ll res=0;
    for(int i=0;i<N;i++){
        for(auto e : G[ans[i]]){
            dp[e]=max(dp[e],dp[ans[i]]+1);
        }
    }

    for(int i=0;i<N;i++){
        res=max(res,dp[i]);
    }


    cout << res<< endl;


    return 0;
}


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

int main() {
  
  long long N;
  cin >> N;
  
  vector<long long> As(N);
  for(int i=0; i<N; i++){ cin >> As.at(i); }
  
  long long res=0;
  long long minn=abs(As.at(0));
  long long mainasu=0;
  
  if(As.at(0)>0){ mainasu=0; }
  else{ mainasu++; }
  
  for(long long i=1; i<N; i++){
    minn = min( minn, abs(As.at(i)) );
    if(As.at(i)<0){ mainasu++; }
  }
  for(long long i=0; i<N; i++){ res+=abs(As.at(i)); }
  if(mainasu%2==1){ res-=2*minn; }
  
  cout << res << endl;

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int R,G,B;
ll pat[3030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	pat[0]=1;
	FOR(i,3) {
		cin>>x;
		for(j=0;j+x<=3010;j++)  (pat[j+x]+=pat[j]);
	}
	
	cin>>x;
	cout<<pat[x]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
    int N; cin >> N;
    int A[N], B[N], C[N], ans = 0;
    rep(i, N) cin >> A[i], A[i]--;
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];

    rep(i, N){
        ans += B[A[i]];
        if(i != 0 && A[i-1] + 1 == A[i]) ans += C[A[i-1]];
    }
    cout << ans << endl;
}

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

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

  int n, m, c;
  cin >> n >> m >> c;
  int b[m];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      sum += a * b[j];
    }
    if (sum + c > 0) {
      count++;
    }
  }
  cout << count << '\n';
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n,m,c=map(int,input().split())
B=input().split(" ")
count=0
for i in range(n):
    A=[]
    ans=0
    A=input().split(" ")
    for j in range(m):
        ans+=int(A[j])*int(B[j])
    if(ans+c>0):
        count+=1
    
print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

#define INF 1000000000000000000LL

ll dp[1010];
 
int main() {
	ll n,m;
	cin>>n>>m;
	rep(i,0,1010){
		dp[i] = -INF;
	}
	vector<pair<pair<ll,ll>,ll> > vp;
	rep(i,0,m){
		ll a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		vp.pb(mp(mp(a,b),c));
	}
	dp[0] = 0;
	rep(i,0,10000){
		rep(j,0,m){
			dp[vp[j].fi.se] = max(dp[vp[j].fi.se],dp[vp[j].fi.fi]+vp[j].se);
		}
	}
	ll ans1 = dp[n-1];
	rep(i,0,10000){
		rep(j,0,m){
			dp[vp[j].fi.se] = max(dp[vp[j].fi.se],dp[vp[j].fi.fi]+vp[j].se);
		}
	}
	ll ans2 = dp[n-1];
	if(ans2>ans1)cout << "inf" << endl;
	else cout << ans1 << endl;	
	return 0;
}

Measured memory_bytes: 384
nu1,nu2 = gets.chomp.split(" ").map(&:to_i)
candle = gets.chomp.split(" ").map(&:to_i)
left = 0
right = nu2 - 1
result = 10**9
time = 10**9

for i in 0..nu1 - nu2
  left = i
  right = nu2 - 1 + i
  time = candle[left].abs + (candle[right] - candle[left]).abs
  if time < result
    result = time
  end
  time = candle[right].abs + (candle[left] - candle[right]).abs
  if time < result
    result = time
  end
end

print result


Measured memory_bytes: 11404
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    set<int>st;
    rep(i,n){
        int x;
        cin >> x;
        st.insert(x);
    }
    if(st.size() == n){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int ans = 0;
  int n;
  cin >> n;
  string s;
  cin >> s;
  int l = 0, r = n - 1;
  while (l < r) {
    while (l < r && s[l] != 'W') l++;
    while (l < r && s[r] != 'R') r--;
    if (l < r && s[l] == 'W' && s[r] == 'R') {
      swap(s[l], s[r]);
      ans++;
      l++, r--;
    }
  }
  int lastr = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') lastr = i;
  }
  for (int i = 0; i < lastr; i++) {
    if (s[i] == 'W') ans++;
  }
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3772
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}


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


int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) cin >> a[i];

    a[0] = 201;
    int min = 200;
    ll ans = 1000;
    ll x;
    for (int i = 1; i <= n; i++) {
        if (a[i] < min) min = a[i];
        if (i == n) {
            if (min < a[n]) {
                x = ans/min;
                ans += (a[n]-min)*x;
            }
        }
        else if (a[i-1] <= a[i]) {
            x = ans/min;
            ans += (a[i]-min)*x;
            min = a[i];
        }
    }

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

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

//		long ans2 = 0;
//		long ans = 0;
//		int ans = 0;

		Scanner sc = new Scanner(System.in);


		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();

//		String string = sc.next();
//		StringBuilder s = new StringBuilder(string);

		boolean f = false;
		boolean f2 = false;
		String s ="";
//
		String[][] a = new String[h][w];
//		int[] b = new int[n];
		int[][] aa = new int[h][w];
//		int[] bb = new int[n];
		for (int i = 0; i < h; i++) {
			s = sc.next();
			for(int j = 0; j < w; j++) {
				a[i][j] = String.valueOf(s.charAt(j));
				aa[i][j] = 0;
			}
		}
//		for (int i = 0; i < n; i++) {
//			b[i] = sc.nextInt();
//			bb[i] = b[i];
//		}

		int index = 0;
		int nonum = 0;


		for (int i = 0; i < h; i++) {
			index++;
			f = false;
			for(int j = 0; j < w; j++) {
				if(a[i][j].equals("#") && f){
					index++;
				}
				if(a[i][j].equals("#") && !f) {
					f = true;
//					System.err.println("aaaaaa");
				}
				aa[i][j] = index;

			}
			f2 = false;
			if(!f) {
				nonum++;
				index += -1;
				f2 = true;
			} else {

				for(int d =1; d <= nonum; d++) {
					for(int jj = 0; jj < w; jj++)
					aa[i-d][jj] = aa[i][jj];
				}

				nonum = 0;
			}
		}

		if(f2) {
			for(int d =0; d < nonum; d++) {
				for(int jj = 0; jj < w; jj++)
				aa[h-1-d][jj] = aa[h-1-nonum][jj];
			}
		}
		for (int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				System.out.print(aa[i][j]);;
				System.out.print(" ");
			}
			System.out.println("");
		}

		sc.close();
	}
}

Measured memory_bytes: 51476
'use strict';
function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const n = Number(input[0]);
  const a = input[1].split(' ').map(Number);

  let count = 0;
  let now = 1;

  for(let i = 0; i < n; i++){
    if(a[i] !== now) {
      count++;
      continue;
    }
    now++;
  }
  if(count === n){
    console.log(-1);
  }else{
    console.log(count);
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22244
N = int(input())
a = list(map(int, input().split()))

num4 = 0
num2 = 0
num1 = 0
for aa in a:
    if aa % 4 == 0:
        num4 += 1
    elif aa % 2 == 0:
        num2 += 1
    else:
        num1 += 1

if num2 == 0:
    if num1 <= num4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if num1 <= num4:
        print('Yes')
    else:
        print('No')


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    int n;
    cin >> n;
    int ans=0, i=0;
    while(ans<=n){
        ++i;
        ans += i;

        if(ans == n)
            break;
    }
    cout << min(n, i);
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll a, b, c;
string s, t, N;
ll ans;
int main(){
	cin >> N;
	ll M = N.size();
	ll carry = 0;
	RREP(i, 0, M){
		ll now = N[i] - '0' + carry;
		if(now > 5){
			ans += 10 - now;
			carry = 1;
		}else if(now == 5){
			carry = (i>=1 && N[i-1] - '0' >= 5);
			ans += 5;
		}else{
			ans += now;
			carry = 0;
		}
	}
	ans += carry;
	p(ans);
	return 0;
}

Measured memory_bytes: 1412
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;

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


int H, W;
char mas[55][55];

bool f[55][55];

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

   cin >> H >> W;
   rep(i, H) {
      cin >> mas[i];
   }

   rep(i, H) {
      rep(j, W) {
         if (mas[i][j] == '.') continue;

         rep(k, 4) {
            int ny = i+dy[k];
            int nx = j+dx[k];
            if (ny>=0 && ny<H && nx>=0 && nx<W) {
               if (mas[ny][nx] == '#') {
                  f[i][j] = f[ny][nx] = true;
               }
            }
         }
      }
   }

   bool ok = true;
   rep(i, H) {
      rep(j, W) {
         if (mas[i][j] == '#'){
            if(f[i][j]) continue;
            else {
               ok = false;
               goto HOGE;
            }
         }
      }
   }

HOGE:
   outl(ok ? "Yes" : "No");

}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n;
    int A[2][n],S1[n],S2[n];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
        cin>>A[i][j];
    }
    }
    S1[0]=A[0][0];
    S2[0]=A[1][0];
    for(int i=1;i<n;i++){
        S1[i]=A[0][i]+S1[i-1];
        S2[i]=A[1][i]+S2[i-1];
    }
    m=S1[0]+S2[n-1];
    for(int i=1;i<n;i++){
        if(S1[i]+S2[n-1]-S2[i-1]>m){
            m=S1[i]+S2[n-1]-S2[i-1];
        }
    }
    cout<<m;

}

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

int main(){
  int N,M,C;cin>>N>>M>>C;
  int B[M];
  for(int i=0;i<M;i++) cin>>B[i];
  int A[N][M];
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++) cin>>A[i][j];
  }
  
  int ans=0;
  for(int i=0;i<N;i++){
    int X=C;
    for(int j=0;j<M;j++) X+=A[i][j]*B[j];
    if(X>0) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int n;
int res=1;
int a[11];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		res*=3;
	}
	int ans=1;
	for(int i=0;i<n;i++){
		if(a[i]%2==0){
			ans*=2;
		}
	}
	cout<<res-ans;
    return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2002000;
const int MOD = 1000 * 1000 * 1000 + 7;

LL F[MAX];
LL IF[MAX];

LL bpow(LL a, LL b)
{
	LL res = 1;
	while(b)
	{
		if (b & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}

	return res;
}

LL inv(LL a)
{
	return bpow(a, MOD - 2);
}

LL C(int n, int k)
{
	LL res = F[n];
	res *= IF[k];
	res %= MOD;
	res *= IF[n-k];
	res %= MOD;
	return res;
}

LL get(int x1, int y1, int x2, int y2)
{
	x2 -= x1;
	y2 -= y1;
	x2 = abs(x2);
	y2 = abs(y2);

//	cout<<"!! "<<x2<<' '<<y2<<endl;
	return C(x2 + y2, x2);
}

LL solve(int x1, int y1, int x2, int y2, int a, int b, int c, int d)
{
	LL res = 0;

//	cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
//	cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<endl;

	FOR (i, a, b+1)
	{
		LL cur = get(x1, y1, i, c-1) * get(i, c, x2, y2);
		cur %= MOD;
		cur *= -(i + c - 1);
		cur %= MOD;
	//	cout<<i<<": "<<cur<<endl;
		cur += MOD;
		cur %= MOD;

		res += cur;

		cur = get(x1, y1, i, d) * get(i, d+1, x2, y2);
		cur %= MOD;
		cur *= i + d;
		cur %= MOD;
	//	cout<<i<<": "<<cur<<endl;

		res += cur;
	}


	FOR (i, c, d+1)
	{
		LL cur = get(x1, y1, a-1, i) * get(a, i, x2, y2);
		cur %= MOD;
		cur *= -(a - 1 + i);
		cur %= MOD;
	//	cout<<i<<": "<<cur<<endl;
		cur += MOD;
		cur %= MOD;

		res += cur;

		cur = get(x1, y1, b, i) * get(b+1, i, x2, y2);
		cur %= MOD;
		cur *= (b + i);
		cur %= MOD;
	//	cout<<i<<": "<<cur<<endl;

		res += cur;
	}
	res %= MOD;
	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	F[0] = 1;
	IF[0] = 1;

	FOR (i, 1, MAX)
	{
		F[i] = (F[i-1] * i) % MOD;
		IF[i] = inv(F[i]);
	}

	int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;

	cin>>x1>>x2>>x3>>x4>>x5>>x6;
	cin>>y1>>y2>>y3>>y4>>y5>>y6;

	x1--;
	y1--;
	x6++;
	y6++;

	vector<PII> a, b;
	a.PB(MP(x1, y1));
	a.PB(MP(x1, y2));
	a.PB(MP(x2, y1));
	a.PB(MP(x2, y2));

	b.PB(MP(x5, y5));
	b.PB(MP(x5, y6));
	b.PB(MP(x6, y5));
	b.PB(MP(x6, y6));

	VI c;
	c.PB(1);
	c.PB(-1);
	c.PB(-1);
	c.PB(1);

	LL res = 0;
	FOR (i, 0, 4)
	{
		FOR (j, 0, 4)
		{
		//	i = 3;
		//	j = 0;
			LL cur = solve(a[i].first, a[i].second, b[j].first, b[j].second, x3, x4, y3, y4);
		//	cout<<i<<' '<<j<<": "<<cur<<endl;
		//	return 0;
			cur *= c[i] * c[j];
			res += cur;
		}
	}

	res %= MOD;
	res += MOD;
	res %= MOD;

	cout<<res<<endl;


}


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

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
 

using ll = long long int;
using ld = long double;
using pii = pair<int,int>;

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
 
using vi=vc<int>;

const ll mod=1e9+7;
const ll INF = 1e18;
const int MAX = 700000;
const int MOD = 1000000007;


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(){
    cout << fixed; cout << setprecision(20);
  int x,y;
  cin >> x >>y;
  if((x+y)%3!=0){
    cout<<0;}
  else{
    COMinit();
    ll m=(2*x-y)/3;
    ll n=x-2*m;
    cout << COM(n+m,n) << endl;
  }
}

Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>

using namespace std;

int main(){
   string w;
   cin>>w;
   vector<int> cnt(26);
   for(int i=0;i<w.size();i++)cnt[w[i]-'a']++;
   for(int i=0;i<26;i++){
      if(cnt[i]%2!=0){
         cout<<"No"<<endl;
         return 0;
      }
   }
   cout<<"Yes"<<endl;
}

   


Measured memory_bytes: 256
use std::io;

// https://atcoder.jp/contests/abc051/tasks/abc051_b
// https://qiita.com/hatoo@github/items/fa14ad36a1b568d14f3e

fn main() {
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let s: usize = iter.next().unwrap().parse().unwrap();

    let mut pattern = 0;
    for z in 0..(k+1) {
        for x in 0..(k+1) {
            let f = s as i16;
            let g = (z + x) as i16;
            let y = f-g;
            if (y >= 0) && (y <= k as i16) {
                pattern += 1;
            }
        }
    }
    println!("{}", pattern);
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int[] nums = new int[10];

                for (int i = 0; i < 10; i++)
                {
                    nums[i] = int.Parse(input[i].ToString());
                }

                for (int i = 9; i > 0; i--)
                {
                    for (int j = 0; j < i; j++)
                    {
                        nums[j] = (nums[j] + nums[j + 1]) % 10;
                    }
                }
                sb.AppendLine(nums[0].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
const int N = 105, K = 1e5 + 5, mod = 1e9 + 7;
int a[N], dp[N][K];
int sum(int a, int b){
  return (a + b) % mod;
}
int sub(int a, int b){
  return (a - b + mod) % mod;
}
int main(){
  int n, k;
  cin >> n >> k;
  for(int i = 1 ; i <= n ; i++)
    cin >> a[i];
  for(int i = 0 ; i <= k ; i++){
    if (i <= a[1])
      dp[1][i] = i + 1;
    else
      dp[1][i] = dp[1][i - 1];
  }
  for(int i = 2 ; i <= n  ;i++){
    for(int j = 0 ; j <= k ; j++){
      int lo = max(0, j - a[i]);
      if (lo)
        dp[i][j] = sub(dp[i - 1][j], dp[i - 1][lo - 1]);
      else
        dp[i][j] = dp[i - 1][j];
      if (j)
        dp[i][j] = sum(dp[i][j], dp[i][j - 1]);
    }
  }
  cout << sub(dp[n][k], dp[n][k - 1]) << endl;
  return 0;
}


Measured memory_bytes: 40832
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 80000+5
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(ll &f){
    f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int a,b;
int main(){
    cin>>a>>b;
    for(int i=0;i<=1100;i++){
        if(i*8/100==a && i*10/100==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 256
a1,a2,a3= map(int,input().split())
a = [a1,a2,a3]
i=0
sum = 0
amin = min(a)
del(a[a.index(amin)])
sum += min(a)-amin
amin = min(a)
del(a[a.index(amin)])
sum += min(a)-amin
print(sum)


Measured memory_bytes: 3060
n,m = map(int,input().split())
s = [0] * m
ans = 0
for i in range(m):
    s[i] = list(map(int,input().split()))
    s[i] = s[i][1:]
p = list(map(int,input().split()))
for k in range(2**n):
    a = format(k,'0'+str(n)+'b')
    t = True
    for i in range(m):
        if sum(a[j-1] == '1' for j in s[i])%2 != p[i]:
            t = False
            break
    ans += t
print(ans)


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

int f(int64_t n) {
  int res = 0;
  while (n) {
    res++;
    n /= 10;
  }
  return res;
}

signed main(int argc, char *argv[]) {
  int64_t n = in();

  int ans = inf;
  for (int i = 1; i <= 100000; ++i) {
    if ((n / i) * i == n) chmin(ans, max(f(i), f(n / i)));
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
#define ll long long
const int pmax = 100005;
const int emax = 400005;
struct node { int to; int w; int next; } edge[emax];
int head[pmax], id = 0, vis[pmax];
int dis[pmax];
inline void add(int x, int y, int w) {
    edge[id].to = y;
    edge[id].w = w;
    edge[id].next = head[x];
    head[x] = id++;
}

bool dfs(int u) {
    vis[u] = 1;
    for (int i = head[u]; ~i; i = edge[i].next) {
        int v = edge[i].to;
        if (!vis[v]) {
            dis[v] = dis[u]+edge[i].w;
            if (!dfs(v)) return false;
        } else if (dis[u]+edge[i].w != dis[v]) return false;
    }
    return true;
}
int main(int argc, char const *argv[])
{
    int n, m;
    int a, b, c;
    memset(head, -1, sizeof head);
    memset(vis, 0, sizeof vis);
    memset(dis, 0, sizeof dis);
    cin >> n >> m;
    while (m--) {
        cin >> a >> b >> c;
        add(a, b, c); add(b, a, -c);
    }
    for (int i = 1; i <= n; i++)
        if (!vis[i]) {
            if (!dfs(i)) return 0*printf("No\n");
        }
    printf("Yes\n");
    return 0;
}


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

int count(vector<int> A, int N, int c){
  bool a = true;
  for(int i=0; i<N; i++){
  	if(A.at(i)%2 != 0){
  	  a = false;
      return 0;
    }   
  }    
  if(a==true){
    for(int i=0; i<N; i++){
  	  A.at(i) /=2;
    }    
    return 1 + count(A, N, c++);
  }
}

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i=0; i<N; i++){
  	cin >> A.at(i);
  }
  //for(int i=0; i<N; i++){
  int c=0;
  cout << count(A,N,c) << endl;
  //}
}

Measured memory_bytes: 256
n, target = map(int, input().split())

result = [-1, -1, -1]
for yukichi in range(n+1):
    for nitobe in range(n+1 - yukichi):
        natsume = n - yukichi - nitobe
        all = yukichi + nitobe + natsume
        total = yukichi*10000 + nitobe*5000 + natsume*1000
        if total == target:
            result = [yukichi, nitobe, natsume]

print(' '.join([str(n) for n in result]))

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

using Graph = vector<vector<int>>;
Graph G;

void dfs(int v, vector<bool> &seen, int &res){
    bool end = true;
    for(int i = 0; i < seen.size(); i++) {
        if(!seen.at(i) && i != v) end = false;
    }
    if(end) {
        ++res;
        return;
    }
    
    seen.at(v) = true;
    for(auto nv : G.at(v)) {
        if(seen.at(nv)) continue;
        dfs(nv, seen, res);
    }
    seen.at(v) = false;
}

int main(void){
    int n,m; cin >> n >> m;
    G.assign(n,vector<int>());
    for(int i = 0; i < m; i++) {
        int a,b; cin >> a >> b; a--,b--;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }
    vector<bool> seen(n, false);
    int res = 0;
    dfs(0,seen,res);
    cout << res << endl;
}


Measured memory_bytes: 256