akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramC
    {
        static void Main()
        {
            int n = NextInt, m = NextInt;
            var matrix = Enumerable.Range(0, n).Select(_ => new List<int>()).ToArray();
            for (int i = 0; i < m; i++)
            {
                foreach (var item in IntList.Skip(1))
                {
                    matrix[item - 1].Add(i);
                }
            }
            var p = IntList;
            int count = 0;

            for (int i = 0; i < (1 << n); i++)
            {
                var array = p.ToArray();
                for (int j = 0; j < n; j++)
                {
                    if ((i & (1 << j)) > 0)
                    {
                        foreach (var item in matrix[j])
                        {
                            array[item]++;
                        }
                    }
                }

                if (array.All(x => x % 2 == 0)) count++;
            }

            System.Console.WriteLine(count);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13524
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;

int main(){
    int N,T,c=100000;
    cin>>N>>T;
    for(int i=0;i<N;i++){
        int a,b; cin>>a>>b;
        if(b<=T) c=min(c,a);
    }

    if(c==100000) cout<<"TLE"<<endl;
    else cout<<c<<endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
template<class T>inline
bool is_prime(T n) {
  if(n==2)return true;
  if(n<2||n%2==0)return false;
  for(T i=3;i*i<=n;i+=2){
    if(n%i==0)return false;
  }
  return true;
}
int main(void){
  long n;
  cin>>n;
  vector<long>num(n);
  long cnt=0;
  for(int i=0;i<n;i++){
    cin>>num[i];
    if(is_prime(num[i]))cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n,k,i,x,sum=0;
     cin>>n>>k;
     vector<int> a;
     for(i=0;i<n;i++)
     {
       cin>>x;
       a.push_back(x);
     }
     sort(a.begin(),a.end());
     for(i=0;i<k;i++)
     {
       sum+=a[i];
     }
     cout<<sum;
     return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=205,up=60;
int n;
ll a[N],p[N];
char s[N];
void add(ll x)
{
    for(int i=up;i>=0;i--)
        if(x>>i&1)
        {
            if(!p[i]) {p[i]=x;break;}
            else x=x^p[i];
        }
}
bool query(ll x)
{
    for(int i=up;i>=0;i--)
        if(x>>i&1)
    {
        if(!p[i]) return true;
        else x=x^p[i];
    }
    return false;
}
int main()
{
    int t;scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
        scanf("%s",s+1);
        if(s[n]=='1')
        {
            printf("1\n");continue;
        }
        memset(p,0,sizeof(p));
        int ans=0;
        for(int i=n;i>=1;i--)
        if(s[i]=='0') add(a[i]);
        else if(query(a[i]))
        {
            ans=1;break;
        }
        printf("%d\n",ans);
    }
}


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

using namespace std;

int main() {
    vector<int> dx = {0, 0, -1, 1};
    vector<int> dy = {-1, 1, 0, 0};
    
    
    int h ,w;
    cin >> h >> w;
    
    vector<vector<char>> table(h, vector<char>(w, 0));
    
    int count = 0;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            cin >> table[i][j];
            if (table[i][j] == '.')
            {
                count++;
            }
        }
    }
    
    vector<vector<int>> dp(h, vector<int>(w, 30000));
    
    dp[0][0] = 1;
    
    bool flag = 1;
    while (flag)
    {
        flag = 0;
        for (int i = 0; i < h; ++i)
        {
            for (int j = 0; j < w; ++j)
            {
                if (table[i][j] == '.')
                {
                    for (int k = 0; k < dx.size(); ++k)
                    {
                        int nextx = j + dx[k];
                        int nexty = i + dy[k];
                        
                        if (nextx >= 0 && nextx < w && nexty >= 0 && nexty < h)
                        {
                            if (table[nexty][nextx] == '.')
                            {
                                if (dp[nexty][nextx] > (dp[i][j] + 1))
                                {
                                    dp[nexty][nextx] = dp[i][j] + 1;
                                    flag = 1;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    if (dp[h - 1][w - 1] == 30000)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << count - dp[h - 1][w - 1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
S = input()
A = list(S)

flg = True
for i in range(len(A)):
  if i%2 == 0:
    if A[i] != 'R' and A[i] != 'U' and A[i] != 'D':
      flg = False
      break
  else:
    if A[i] != 'L' and A[i] != 'U' and A[i] != 'D':
      flg = False
      break

if flg:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			if (n == 0)
				return;
			strs = new String[n];
			for (int i = 0; i < n; i++) {
				strs[i] = scanner.next();
			}
			System.out.println(solve() ? "OK" : "NG");
		}
	}

	private boolean solve() {
		int[] in = new int[26], out = new int[26];
		UnionFind unionFind = new UnionFind(26);
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			int from = (int) (strs[i].charAt(0) - 'a');
			int to = (int) (strs[i].charAt(strs[i].length() - 1) - 'a');
			in[from]++;
			out[to]++;
			list.add(from);
			unionFind.merge(from, to);
		}
		for (int i = 0; i < 26; i++) {
			if (in[i] != out[i]) {
				return false;
			}
		}
		for (int i = 1; i < list.size(); i++) {
			if (!unionFind.isSame(list.get(0), list.get(i))) {
				return false;
			}
		}

		return true;
	}

	int n;
	String[] strs;

	class UnionFind {
		int[] pars;
		int[] rank;

		@Override
		public String toString() {
			return "UnionFind [pars=" + Arrays.toString(pars) + ", rank="
					+ Arrays.toString(rank) + "]";
		}

		UnionFind(int size) {
			pars = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++)
				pars[i] = i;
		}

		int root(int x) {
			if (x == pars[x])
				return x;
			return pars[x] = root(pars[x]);
		}

		boolean isSame(int x, int y) {
			return root(x) == root(y);
		}

		void merge(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (rank[x] > rank[y])
				pars[y] = x;
			else {
				pars[x] = y;
				if (rank[x] == rank[y])
					rank[y]++;
			}
		}
	}
}

Measured memory_bytes: 48248
from collections import deque


class Process:

    def __init__(self, name, left):
        self.name = name
        self.left = left


def deal(quantam, pslist: [Process]):
    queue = deque(pslist)
    elaps = 0

    while queue:
        ps = queue.popleft()
        take = min(quantam, ps.left)
        ps.left -= take
        elaps += take
        if ps.left > 0:
            queue.append(ps)
        else:
            print(ps.name, elaps)


if __name__ == '__main__':
    n, q = [int(x) for x in input().split()]
    pslist = []
    for _ in range(int(n)):
        name, need = input().split()
        pslist.append(Process(name, int(need)))
    deal(q, pslist)



Measured memory_bytes: 18168
N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
n = list(range(1,N+1))
s = [0]*(N+1)
s[0] = n[0]
for i in range(1,N+1): s[i] = s[i-1] * n[i-1]
vp=0
for i in range(N):
        p=n.index(P[i])
        vp += s[N-i-1] * p
        n.pop(p)
n = list(range(1,N+1))
vq=0
for i in range(N):
        p=n.index(Q[i])
        vq += s[N-i-1] * p
        n.pop(p)

print(abs(vp-vq))

Measured memory_bytes: 3064
import java.util.Scanner;

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

	int a = scan.nextInt();
	int b = scan.nextInt();
	
	if(a < b){
		System.out.println("a < b");
	}
	else if(a > b){
		System.out.println("a > b");
	}
	else{
		System.out.println("a == b");
	}
	}
}

Measured memory_bytes: 26108
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010,Mod=1e9+7;
char s[N];
int n,a[N];
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	int l=1;s[n+1]='R';
	for(int i=2;i<=n+1;i++)
		if(s[i]!=s[i-1]){
			int r=i-1;
			if(s[i]=='L'){
				for(int j=l;j<=r;j++)
					if((i-j)&1)a[r]++;
					else a[i]++;
			}
			else{
				for(int j=l;j<=r;j++)
					if((j-l)&1)a[l-1]++;
					else a[l]++;
			}
			l=i;
		}
	for(int i=1;i<=n;i++)
		printf("%d%c",a[i],i==n?'\n':' ');
	return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

      String line;
      StringBuilder lowered = new StringBuilder();
      char c;
      char ca = "a".charAt(0);
      char cz = "z".charAt(0);
      int[] count = new int[26];

      while(true) {
        line = br.readLine();
        if ( line  == null || line.isEmpty() ) break;

        lowered.append(line.toLowerCase());
        for ( int i = 0; i < lowered.length(); i++ ) {
          c = lowered.charAt(i);
          if( ca > c || c > cz) continue;
          count[(c-ca)] += 1;
        }
        lowered.setLength(0);

      }

      for ( int i = 0; i < count.length; i++ ) {
        System.out.println(Character.valueOf((char)(ca + (char)i)).toString() + " : " + count[i]);
      }
    }
  }
}


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

using namespace std;

int ans, score, n, m, c, b[20], a[20][20];

int main(){
	cin >> n >> m >> c;
	for(int i = 0; i < m; ++i) cin >> b[i];
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			cin >> a[i][j];
		}
	}
	
	for(int i = 0; i < n; ++i){
		score = c;
		for(int j = 0; j < m; ++j){
			score += a[i][j] * b[j];
		}
		if(score > 0) ans++;
	}	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma optimise("-O3")
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
// int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}

/*
 
REMOVE DEBUG STATEMENTS
CHECK FOR DUPLICATES (SET -> MULTISET)
CLEAR EVERYTHING BEFORE EVERY TESTCASE
ceil(x/2.0)
floor(x/2.0)
 
*/
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};

template<class T> bool ckmin(T&a, T&b) { bool B = a > b; a = min(a,b); return B; }
template<class T> bool ckmax(T&a, T&b) { bool B = a < b; a = max(a,b); return B; }

void solve(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<nl;
    return ;
}
int main()
{
    IO;
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}//multiset m make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue 
//cout<<setprecision(12);

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N;
  double tmp1, tmp2; 
  
  cin >> N;

  if(N!=1){
    tmp1 = (N+1)/2;
    tmp2 = tmp1/N; 
    
    printf("%10f\n",tmp2); 
  }else{
    cout << "1.00";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=605,M=1e9+7;
int flag[N],x,y,n,dp[2][N][N],cnt;
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++){
		scanf("%lld%lld",&x,&y);
		if (x==-1&&y==-1)cnt++;
		else if (x!=-1&&y!=-1)flag[x]=flag[y]=2;
		else if (x==-1&&y!=-1)flag[y]=1;
		else flag[x]=1;
	}
	dp[1][0][0]=1;
	for (int i=2*n;i;i--){
		int t=i&1;
		for (int j=0;j<=2*n;j++)
			for (int k=0;k<=2*n;k++)
				if (flag[i]==2)dp[t][j][k]=dp[t^1][j][k];
				else if (flag[i]==1)dp[t][j][k]=(dp[t^1][j][k+1]+(!j?0:dp[t^1][j-1][k]))%M;
				else dp[t][j][k]=(dp[t^1][j+1][k]*(j+1)+(!k?0:dp[t^1][j][k-1])+dp[t^1][j][k+1])%M;
		memset(dp[t^1],0,sizeof dp[t^1]);
	}
	int ans=dp[1][0][0];
	for (int i=1;i<=cnt;i++)(ans*=i)%=M;
	printf("%lld\n",ans);
}


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

int main() {
	int n;
	cin>>n;
	while(n>0){
		int a[3];
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		if(a[2]*a[2]==a[1]*a[1]+a[0]*a[0]){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
		n--;
	}
	
	return 0;
}

Measured memory_bytes: 3024
N = int(input())
A = list(map(int,input().split()))
S = [0]
for i in range(N):
    S.append(S[i]+A[i])
S.sort()
now = S[0]
s = 1
ans = 0
for i in range(1,N+1):
    if now == S[i]:
        s += 1
    else:
        ans += s*(s-1)//2
        s = 1
    now = S[i]
ans += s*(s-1)//2
print(ans)


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

int main() {
  int N;
  int i, s;
  cin >> N;
  vector<int> a(N);
  for (i=0; i<N; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for (i=0, s=0; i<N; i++) {
    s += a.at(i);
    i++;
    if (i < N) s-=a.at(i);
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int mod = 924844033;
int N, K, sub[2009][2009][3], val[2009][2009], dp[2009][2009], fact[2009];
int main() {
	cin >> N >> K;
	fact[0] = 1;
	for (int i = 1; i <= N; i++) fact[i] = 1LL * fact[i - 1] * i % mod;
	sub[0][0][0] = 1; val[0][0] = 1;
	sub[1][0][0] = 1; val[1][0] = 1;
	for (int i = 2; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			sub[i][j][0] = val[i - 1][j];
			if (j >= 1) sub[i][j][1] = (sub[i - 1][j - 1][0] + sub[i - 1][j - 1][1]) % mod;
			if (j >= 1) sub[i][j][2] = sub[i - 1][j - 2][0];
			val[i][j] = ((sub[i][j][0] + sub[i][j][1] * 2 % mod) % mod + sub[i][j][2]) % mod;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < K; i++) {
		int num = N / K + (N % K > i ? 1 : 0);
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k <= num && k <= j; k++) {
				dp[i + 1][j] = (dp[i + 1][j] + 1LL * dp[i][j - k] * val[num][k]) % mod;
			}
		}
	}
	int ret = 0;
	for (int i = 0; i <= N; i++) {
		if (i % 2 == 0) ret = (ret + 1LL * fact[N - i] * dp[K][i]) % mod;
		else ret = (ret - 1LL * fact[N - i] * dp[K][i] % mod + mod) % mod;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 78848
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Dec 23 23:26:20 2018
//
package main

import "fmt"

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var N int
	fmt.Scan(&N)
	if N == 0 {
		fmt.Println(0)
		return
	}

	ans := make([]int, 0)
	for N != 0 {
		var rem int
		if N < 0 && N%-2 != 0 {
			N--
			rem = 1
		}
		rem += abs(N % 2)
		ans = append(ans, rem)
		N /= -2
	}

	for i := len(ans) - 1; i >= 0; i-- {
		fmt.Print(ans[i])
	}
	fmt.Println()
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))

flg = True
for a in A:
    if a%2 == 0:
        if not (a%3==0 or a%5==0):
            flg = False
            break
        
if flg:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[10][2000],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,2)rep(j,n)cin>>a[i][j];
    rep(i,n){
        cnt=0;
        rep(j,i+1)cnt+=a[0][j];
        rrep(j,i,n)cnt+=a[1][j];
        ans=max(ans,cnt);
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;
typedef pair<int,int> P;


int main()
{
  char A[4];
  for(int i=0;i<4;i++)cin>>A[i];
  int a[4];
  for(int i=0;i<4;i++)a[i]=A[i]-'0';
  bool flag=false;

  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
	int ans=a[0];
	if(i)ans+=a[1];
	else ans-=a[1];
	if(j)ans+=a[2];
	else ans-=a[2];
	if(k)ans+=a[3];
	else ans-=a[3];

	if(ans==7){
	  flag=true;
	  cout<<a[0]<<(i==1?'+':'-')<<a[1]<<(j==1?'+':'-')<<a[2]<<(k==1?'+':'-')<<a[3]<<"=7"<<endl;
	}

	if(flag)break;
      }
	if(flag)break;
    }
	if(flag)break;
  }


  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	cout<<"";
        }
      	cout<<"";
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
  	cout<<"";
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}


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

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

int main(){
    int h, n; cin >> h >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<vector<ll>> dp(n+1,vector<ll>(h+1,INF));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= h; j++){
            if(j < a[i]){
                dp[i+1][j] = min(dp[i][j], b[i]);
            }else{
                dp[i+1][j] = min(dp[i][j], dp[i+1][j-a[i]]+b[i]);
            }
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 78592
import java.util.Scanner;

public class Main {

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

		int[] t = new int[6];
		for(int i = 0; i < 6; i++) {
			t[i] = sc.nextInt();
		}

		int s = 0;

		s = t[0]*1 + t[1]*5 + t[2]*10 + t[3]*50 + t[4]*100 + t[5]*500;

		if(s>=1000) {
			System.out.println(1);
		}
		else {
			System.out.println(0);
		}

		sc.close();
	}
}	


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

int main() {
	vector<tuple<string, int,int>> score;
	int N,a;
	string s,z="",tmp;
	stack<int> Q,X;
	stack<string> S;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> s >> a;
		score.push_back(make_tuple(s, a,i));
	}
	sort(score.begin(), score.end());
	for (auto p : score) {
		int x, y;
		tmp = z;
		tie(z, x, y) = p;
		if (Q.empty() or tmp == z) {
			X.push(x);
			Q.push(y);
			S.push(z);
		}
		else {
			while (!Q.empty()) {
				//cout << S.top() << " " << X.top() << " " << Q.top() << endl;
				cout << Q.top() << endl;
				S.pop();
				Q.pop();
				X.pop();
			}
			Q.push(y);
			S.push(z);
			X.push(x);
		}
		//printf("%5s %3d %2d\n", z.c_str(),x,y);
	}
	//cout << S.top() << " " << X.top() << " " << Q.top() << endl;
	while (!Q.empty()) {
		cout << Q.top() << endl;
		Q.pop();
	}
}


Measured memory_bytes: 256
_n, m = gets.split.map(&:to_i)

data = m.times.map.with_index do |i|
  p, y = gets.split.map(&:to_i)
  [p, i, y]
end

ken = data.group_by(&:first)

ken.each_value do |cities|
  cities
    .sort_by(&:last)
    .each.with_index(1) {|(_p, data_index, _y), order| data[data_index][2] = order }
end

data.each {|p, _i, y| puts "%06d%06d" % [p, y] }


Measured memory_bytes: 24444
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int a,b;
  cin >> a >> b;
  if(a > b) cout << "a > b" << endl;
  if(a < b) cout << "a < b" << endl;
  if(a == b) cout << "a == b" << endl;
  return 0;
}



Measured memory_bytes: 3124
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        StringBuilder sb=new StringBuilder("");
        int H=sc.nextInt(),W=sc.nextInt();
        while (H!=0||W!=0){
            for(int a=1;a<=H;a++){
                for (int b=1;b<=W;b++){
                    if((a%2==1&&b%2==1)||(a%2==0&&b%2==0)){
                        sb.append("#");
                    }else if((a%2==0&&b%2==1)||(a%2==1&&b%2==0)){
                        sb.append(".");
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
            H=sc.nextInt();W=sc.nextInt();
        }
        System.out.print(sb);
        }
}

Measured memory_bytes: 27392
K = int(input())
import math
sumnation = 0
gcdlist = []
for A in range(1,K+1):
    for B in range(1,K+1):
        gcdlist.append(math.gcd(A,B))
for a in range(1,1+K):
    for b in range(1,1+K):
        gcd_a_b = gcdlist[(a-1)*K+b-1]
        for c in range(1,1+K):
            sumnation += gcdlist[(gcd_a_b-1)*K+c-1]
print(sumnation)

Measured memory_bytes: 9448
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
    A=list(map(int,input().split()))
    p=C
    for j in range(M):p+=A[j]*B[j]
    if p>0:count+=1
print(count)


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(void){

  int a,b;
  scanf("%d %d", &a, &b);
  int digit = 0;
  int number = b;
  while (number > 0) {
    digit++;
    number /= 10;
  }
  a *= pow(10,digit);
  a += b;
  int x = sqrt(a);
  if (x*x == a) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define FF first
#define SS second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define inf 1e18
#define mod 1000000007
#define PI 3.1415926535
#define endl "\n"
#define runtime cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

inline int sbt(int x) {return __builtin_popcount(x);}
inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }



int32_t main() {
	fastio
	int n, m, k;
	cin >> n >> m >> k;
	vector<int>row(n, 0), col(m, 0);
	map<pii, int>gg;
	while (k--) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		row[x]++;
		col[y]++;
		gg.insert({{x, y}, 1});

	}
	int mxr = 0, mxc = 0;
	rep(i, 0, n) {
		mxr = max(mxr, row[i]);
	}
	rep(i, 0, m) {
		mxc = max(mxc, col[i]);
	}
	vector<int>ansr, ansc;
	rep(i, 0, n) {
		if (row[i] == mxr) {
			ansr.pb(i);
		}
	}
	rep(i, 0, m) {
		if (col[i] == mxc) {
			ansc.pb(i);
		}
	}
	int flag = 1;
	int ans = 0;
	rep(i, 0, sz(ansr)) {
		rep(j, 0, sz(ansc)) {
			int r = ansr[i];
			int c = ansc[j];
			flag = 0;
			int fans = row[r] + col[c];
			if (gg.count({r, c}) > 0) {
				fans--;
				flag = 1;
			}

			ans = max(ans, fans);
			if (!flag)break;

		}
		if (!flag)break;

	}
	cout << ans;



	runtime
	return 0;
}


Measured memory_bytes: 35008
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n; char s[N];
int nxt[N][26],dp[N];

int main() {
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=n;i;--i) {
		memcpy(nxt[i],nxt[i+1],sizeof(nxt[i]));
		nxt[i][s[i]-'a']=i;
	}
	memset(dp,0x3f,sizeof(dp));
	for (int i=n;i;--i)
		for (int j=0;j<26;++j) {
			if (!nxt[i][j]) { dp[i]=1; break; }
			dp[i]=min(dp[i],dp[nxt[i][j]+1]+1);
		}
	for (int l=dp[1],p=1;l;--l) {
		if (l==1) {
			for (int i=0;i<26;++i)
				if (!nxt[p][i]) { putchar(i+'a'); break; }
		} else {
			for (int i=0;i<26;++i) {
				if (dp[p]==dp[nxt[p][i]+1]+1) {
					putchar(i+'a'),p=nxt[p][i]+1; break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 24920
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

bool two = true;
ll n, m, s[110000], w = 0, b = 0;
vector<vector<ll>> list(110000);

void dfs(ll a) {
	REP(i, list[a].size()) {
		if (s[list[a][i]] == s[a]) two = false;
		else if (s[list[a][i]] == 0) {
			if (s[a] == 1) {
				s[list[a][i]] = 2;
				b++;
			}
			else {
				s[list[a][i]] = 1;
				w++;
			}
			dfs(list[a][i]);
		}
	}
}

int main() {
	cin >> n >> m;
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		list[a].push_back(b);
		list[b].push_back(a);
	}
	s[1] = 1;
	w++;
	dfs(1);
	cout << (two ? w * b - m : n * (n - 1) / 2 - m) << endl;
}

Measured memory_bytes: 7808
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;

		System.out.print( String.format("%d %d %f", d, r, f) );

//		System.out.printf("%d %d %f", d, r, f);
	}

}

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

#define ll long long
using namespace std;
int a[301][301];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    int k=1000;
    while(k<n){
        k+=1000;
    }
    cout<<k-n<<endl;
    return 0;
}


Measured memory_bytes: 3636
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 079E」Decrease (Judge ver.) 26-08-2017
 * 贪心
 * @author xehoth
 */
#include <bits/stdc++.h>

namespace {

typedef unsigned long long ulong;

const int MAXN = 50;
int n;
ulong a[MAXN];

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    std::cin >> n;
    for (register int i = 0; i < n; i++) std::cin >> a[i];
    register ulong ans = 0, cnt, *p;
    for (; *(p = std::max_element(a, a + n)) >= n;) {
        cnt = *p / n, *p %= n, ans += cnt;
        for (register ulong *i = a; i < p; i++) *i += cnt;
        for (register ulong *i = p + 1; i < a + n; i++) *i += cnt;
    }
    std::cout << ans;
}
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,W;
  cin>>n>>W;
  vll w(n),v(n);
  rep(i,n) cin>>w[i]>>v[i];
  vvll dp(n+1,vll(100010,INF));
  dp[0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=n*1000;j++){
      if(j>=v[i]){
        dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
      }
      else dp[i+1][j]=dp[i][j];
    }
  }
  ll ans;
  rep(i,n*1000+1){
    if(dp[n][i]<=W){
      ans=i;
    }
  }
  COUT(ans);
}

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

int main(){
	int N;
  	cin >> N;
  	int a[2000000];
  	a[0] = N;
  	int I = 0;
  	int ans = 0;
  	while(true){

    	if(a[I]%2==0){
        	a[I+1] = a[I]/2;
        }else{
        	a[I+1] = 3*a[I]+1;
        }
      	//cout << a[I] << endl;
      	for(int i = 0; i < I; i++){
        	if(a[i]==a[I]){
            	ans= I+1;
              	break;
            }
        }
      	if(ans!=0){
        	break;
        }
      

      	I++;

    }
  	cout << ans << endl;
	

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A + B >= C) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
A.sort()

# 累積和取る。
for i in range(1, n):
  A[i] += A[i - 1]

k = 0
for i in range(0, n-1):
  if A[i] * 2 < A[i+1] - A[i]:
    k = i + 1
print(n-k)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, K, Q; cin >> N >> K >> Q;
    vec a(N, 0);
    rep(i, Q){
        int x; cin >> x;
        x--;
        a[x]++;
    }

    rep(i, N){
        if(a[i] > Q - K) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

using ll = long long;

ll a, v, b, w, t;

int main()
{
    cin >> a >> v >> b >> w >> t;
    if (v <= w)
    {
        cout << (a == b ? "YES" : "NO");
        return 0;
    }
    cout << (abs(a - b) <= t * (v - w) ? "YES" : "NO");
    return 0;
}


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

struct edge { int from, to, cost; };

const int MAX_N = (int)205;
const int INF = (int)1e7;
int H, W;
int cost[10][10];
int A[MAX_N][MAX_N];
int d[10][10];

int V = 10;
int E = 100;

edge es[105];

void shortest_path(int s) {
  d[s][s] = 0;
  while (true) {
    bool update = false;
    for (int i = 0; i < E; ++i) {
      edge e = es[i];
      if (d[s][e.from] != INF && d[s][e.to] > d[s][e.from] + e.cost) {
        d[s][e.to] = d[s][e.from] + e.cost;
        update = true;
      }
    }
    if (!update) break;
  }
}

int main(void) {
    // Here your code !
    int tmp;
    scanf("%d %d", &H, &W);
    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < 10; ++j) {
        scanf("%d ", &tmp);
        es[i * 10 + j].from = (int)i;
        es[i * 10 + j].to = (int)j;
        es[i * 10 + j].cost = (int)tmp;
        d[i][j] = INF;
      }
    }
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        scanf("%d", &A[i][j]);
      }
    }

    for (int i = 0; i < 10; ++i) {
      shortest_path(i);
    }

    int ans = 0;
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        if (A[i][j] != -1 && A[i][j] != 1) {
          ans += d[A[i][j]][1];
        }
      }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9+5;
const ll INFLL=1e+17;
int main(){
  int n;cin>>n;
  int f[101][10];
  rep(i,n){
    rep(j,10){
      cin>>f[i][j];
    }
  }
  int p[101][11];
  rep(i,n){
    rep(j,11){
      cin>>p[i][j];
    }
  }
  int res=-INF;
  rep1(i,(1<<10)-1){
    int prof=0;
    rep(j,n){
      int cnt=0;
      rep(k,10){
	if(f[j][k]&i>>k) cnt++;
      }
      prof+=p[j][cnt];
    }
    res=max(res,prof);
  }

  prin(res);
  


  

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 100003, p = 1000000007;
int n, a[N], inv[N], ans, res;
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++)
		scanf("%d", a + i);
	inv[1] = 1;
	for(Rint i = 2;i <= n;i ++)
		inv[i] = (LL) inv[p % i] * (p - p / i) % p;
	for(Rint i = 1;i <= n;i ++)
		inv[i] = (inv[i] + inv[i - 1]) % p;
	for(Rint i = 1;i <= n;i ++)
		ans = (ans + (LL) (inv[n - i + 1] + inv[i] - 1) * a[i]) % p;
	res = 1;
	for(Rint i = 2;i <= n;i ++)
		res = (LL) res * i % p;
	printf("%lld", (LL) ans * res % p);
}

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

#define ll              long long
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             (int)(1e18)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define rep(i,j,n)      for(int i=j;i<n;i++)
#define all(p)          p.begin(),p.end()
#define ub(a,b)         upper_bound(all(a),b)
#define lb(a,b)         lower_bound(all(a),b)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int32_t main()
{
	run();
	int h, w;
	cin >> h >> w;
	vector<vector<int>> dp(h, vector<int>(w, 0)), a(h, vector<int>(w));
	rep(i, 0, h)
	{
		string s;
		cin >> s;
		rep(j, 0, w)
		{
			if (s[j] == '.')
			{
				a[i][j] = 1;
			}
			else {
				a[i][j] = 0;
			}
		}
	}
	dp[0][0] = a[0][0];
	rep(i, 1, h)
	{
		dp[i][0] = (dp[i - 1][0] == 1 and a[i][0] == 1);
	}
	rep(i, 1, w)
	{
		dp[0][i] = (dp[0][i - 1] == 1 and a[0][i] == 1);
	}
	for (int i = 1; i < h; i++)
	{
		for (int j = 1; j < w; j++)
		{
			if (a[i][j] != 0)
			{
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= mod;
			}
			else {
				dp[i][j] = 0;
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 16000
#!/usr/bin/env python

def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

N = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)
# print(t_list)
# print(x_list)
# print(y_list)

is_reachable = False
for i in range(N):
    # t = 0, (x, y) = (0, 0)
    num_steps = t_list[i+1] - t_list[i]
    x_dist = abs(x_list[i+1] - x_list[i])
    y_dist = abs(y_list[i+1] - y_list[i])
    dist = x_dist + y_dist
    # print('i:', i, 'num_steps:', num_steps, 'distance:', dist)
    # print(num_steps >= dist and is_even(num_steps) == is_even(dist))

    if num_steps >= dist and is_even(num_steps) == is_even(dist):
        is_reachable = True
    else:
        is_reachable = False
        break

if is_reachable:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 11852
import Data.List
import Text.Printf

rd :: String -> (Char,Int)
rd (c:n) = (c,read(n)) 
sh :: (Char,Int) -> String
sh (c,n) = printf "%c%d" c n

cmp (_,n1) (_,n2) = compare n1 n2
gt (_,n1) (_,n2) = n1 >  n2
lt (_,n1) (_,n2) = n1 <  n2

-- bubble sort
bubble_iter []     = (False,0,[])
bubble_iter (x:[]) = (False,0,(x:[]))
bubble_iter (x0:x1:xs) =
  let (f,n,x) = if x0 `gt` x1
                then bubble_iter (x0:xs)
                else bubble_iter (x1:xs)
  in
    if x0 `gt` x1
    then (True,n+1,x1:x)
    else (f,   n  ,x0:x)

bubble_sort n x = 
  let (f,n',x') = bubble_iter x
  in 
    if f
    then bubble_sort (n'+n) x'
    else (n'+n,x')

select_sort [] = []
select_sort (x:[]) = (x:[])
select_sort (x0:x1:[]) =
  if x1 `lt` x0
  then (x1:x0:[])
  else (x0:x1:[])
select_sort (x0:xs) =
  let m = minimumBy cmp xs
      h = takeWhile (/= m) xs
      t = tail $ dropWhile (/= m) xs
  in
    if m `lt` x0
    then m:(select_sort $ h ++ [x0] ++ t)
    else x0:(select_sort xs)
   
main = do
  n <- getLine
  c <- getLine
  let i = words c
      o = map rd i
      (_,b) = bubble_sort 0 o
      s = select_sort o
  putStrLn $ unwords $ map sh b
  putStrLn "Stable"
  putStrLn $ unwords $ map sh s
  let r = if b == s
          then "Stable"
          else "Not stable"
  putStrLn r

Measured memory_bytes: 4220