akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
//import java.lang.Math;

public class Main {
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int A[][] = new int[n][m];
    int b[] = new int[m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        A[i][j] = scan.nextInt();
      }
    }
    for (int i = 0; i < m; i++) {
      b[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      int tmp = 0;
      for (int j = 0; j < m; j++) {
        tmp += A[i][j] * b[j];
      }
      System.out.println(tmp);
    }
    scan.close();
  }
}



Measured memory_bytes: 40724
#include<stdio.h>
int main(void){
    int m,f,b;
    scanf("%d%d%d",&m,&f,&b);
    if(b > m+f) printf("NA\n");
    else if(b <= m+f){
        if(b <= m) printf("0\n");
        else       printf("%d\n",b-m);
    } 
}


Measured memory_bytes: 2132
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int gcd(int x, int y)
{
  if(y==0) return x;
  return gcd(y, x%y);
}

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  vector<int> r(n), l(n);
  
  rep(i,n-1) l[i+1] = gcd(l[i],a[i]);
/*
  for(int i=0; i<n; ++i)
  {
    l[i+1] = gcd(l[i],a[i]);
  }
  */
  for(int i=n-1; i>=1; --i)
  {
    r[i-1] = gcd(r[i],a[i]);
  }
  
  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i],r[i]));
  /*
  for(int i=0; i<n; ++i)
  {
    ans = max(ans, gcd(l[i],r[i]));
  }
  */
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#define INF -222222222

void insert(int);
void build();
void Max_h();
int Ex_Max();

int K_c = 0;//配列Kの個数
int E_c = 0;//配列Eの個数
int K[1000000], E[1000000];

int main(){
  int i;
  int k;
  char order[10];

  while(1){
    scanf("%s", order);
    if(order[0] == 'e' && order[1] == 'n'){
      break;
    }else if(order[0] == 'i'){
      scanf("%d", &k);
      insert(k);
    }else if(order[0] == 'e' && order[1] == 'x'){
      E[E_c] = Ex_Max();
      Max_h(1);      
      E_c++;
    }
  }

  for(i = 0; i < E_c; i++){
    printf("%d\n", E[i]);
  }

  return 0;
}

void insert(int k){
  int temp, i;
  
  K_c++;  
  K[K_c] = k;

  i = K_c;

  while(i > 1 && K[i / 2] < K[i]){
    temp = K[i];
    K[i] = K[i / 2];
    K[i / 2] = temp;

    i = i / 2;
  }
}

int Ex_Max(){
  int max;

  max = K[1];
  K[1] = K[K_c];

  K_c--;

  return max;
}

//以下、前問から引用

void Max_h(int i){
  int left, right, largest = 0;
  int temp;

  left = i*2;
  right = i*2 + 1;

  if(left <= K_c && K[left] > K[i]) largest = left;
  else largest = i;

  if(right <= K_c && K[right] > K[largest]) largest = right;

  if(largest != i){
    temp = K[i];
    K[i] = K[largest];
    K[largest] = temp;

    Max_h(largest);
  }
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

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

int N, M;
int a[1050], b[1050], c[1050][20];

void input(){
  cin >> N >> M;
  REP(i, M){
    cin >> a[i] >> b[i];
    REP(j, b[i])
      cin >> c[i][j];
  }
}

void solve(){
  input();
  vll dp(5000, INF);
  dp[0] = 0;
  REP(item, M){
    ll now = 0;
    REP(j, b[item])
      now |= (1 << c[item][j]-1);

    REP(bit, (1<<N))
      chmin(dp[bit|now], dp[bit]+a[item]);
  }

  if(dp[(1<<N)-1] == INF)
    dp[(1<<N)-1] = -1;
  cout << dp[(1<<N)-1] << endl;
  return;

}

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

  solve();
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>

#define FRER() freopen("in.txt","r",stdin)
#define FREW() freopen("out.txt","w",stdout)

using namespace std;

int main()
{
    //FRER();
    int n, t;
    scanf("%d%d",&n,&t);
    int st = 0;
    int vmax = 0;
    int a;
    int ans;
    int i;
    for(i = 0; i < n; i++)
    {
        scanf("%d",&a);
        ans = 1;
        if(a>=vmax)
            ans += (t-st)/a;
        else{
            ans += (t-st)/vmax;
            if((t-st)%vmax>=a) ans+=1;
        }
        printf("%d\n", ans);
        if(ans==1) break;
        vmax = max(a,vmax);
        st+=a;
    }
    for(i=i+1; i < n; i++){
        scanf("%d",&a);
        puts("1");
    }
    return 0;
}



Measured memory_bytes: 3228
#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-1LL;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

double dp[310][310][310];

ll n;

double f(ll a1, ll a2, ll a3){
  if(a1==0&&a2==0&&a3==0){
    return 0.;
  }
  if(dp[a1][a2][a3]!=-1.)return dp[a1][a2][a3];
  ll n1 = n-a1-a2-a3;
  double dd = 1.*n/(n-n1);
  double ret = dd;
  if(a1>0){
    ret += dd*a1*f(a1-1,a2,a3)/n;
  }
  if(a2>0){
    ret += dd*a2*f(a1+1,a2-1,a3)/n;
  }
  if(a3>0){
    ret += dd*a3*f(a1,a2+1,a3-1)/n;
  }
  return dp[a1][a2][a3] = ret;
}

int main() {
  rep(i,0,310)rep(j,0,310)rep(k,0,310)dp[i][j][k]=-1.;
  cin>>n;
  ll a1 = 0;
  ll a2 = 0;
  ll a3 = 0;
  rep(i,0,n){
    ll a;
    cin>>a;
    if(a==1)a1++;
    if(a==2)a2++;
    if(a==3)a3++;
  }
  double ans = f(a1,a2,a3);
  printf("%20.20f\n", ans);
	return 0;
}

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

using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main() {
    fio;
    
    ll n,m;cin>>n;
    
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll t = INT_MAX;
    ll ans=0;
    for(ll i=0;i<n;i++){
        t=min(a[i],t);
        if(t==a[i])
            ans++;
    }
    
    cout<<ans<<endl;
    
	return 0;
}

Measured memory_bytes: 1792
fn main() {
    let abk = read_vec::<u64>();
    let mut a = abk[0];
    let b = abk[1];
    let mut k = abk[2];

    if a > k {
        println!("{} {}", a-k, b);
        return
    }

    k -= a;
    a = 0;

    if b > k {
        println!("{} {}", a, b-k);
        return
    }

    println!("{} {}", 0, 0);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N;
int A[2][100] = { 0 };

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

	cin >> N;
	REP(i, 0, N)	cin >> A[0][i];
	REP(i, 0, N)	cin >> A[1][i];
	
	int ans = 0;
	REP(i, 0, N) {
		int wk = 0;
		REP(j, 0, N) {
			if(j == i) {
			    wk += (A[0][j] + A[1][j]);
			} else if(j < i) {
			    wk += A[0][j];
			} else {
			    wk += A[1][j];
			}
//    		cout << "wk = " << wk << endl;
		}
//		cout << "i = " << i << "  wk = " << wk << endl;
		ans = max(ans, wk);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a,int b)
{
	int tmp,n;
	if(a<b)
	{
		tmp=a;
		a=b;
		b=tmp;
	}
	while(b!=0)
	{
		n=a%b;
		a=b;
		b=n;
	}
	return a;
}
int main()
{
	int N;
	cin>>N;
	vector<int> board(N);
	for(int i=0; i<N; i++)
	{
		cin>>board[i];
	}
	vector<int> left(N);
	vector<int> right(N);
	left[0]=board[0];
	right[N-1]=board[N-1];
	for(int i=1; i<N; i++)
	{
		left[i]=gcd(left[i-1],board[i]);
	}
	for(int i=N-2; i>=0; i--)
	{
		right[i]=gcd(right[i+1],board[i]);
	}
	int gm=-1;
	for(int i=0; i<N; i++)
	{
		int nowgcd=0;
		if(i==0)
		{
			nowgcd=right[1];
		}
		else if(i==N-1)
		{
			nowgcd=left[N-2];
		}
		else
		{
		 	nowgcd=gcd(left[i-1],right[i+1]);	
		}
		gm=max(gm,nowgcd);
	}
	cout<<gm<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll n;
ll ans=0;
int main(){
    cin>>n;
    ll tmp;
    for(ll i=1;i*i<=n;++i)if(n%i==0){
        tmp=n;
        if(i!=1&&i*i!=n){
        while(tmp%i==0) tmp/=i;
        if(tmp%i==1) ++ans;
        }
        tmp=n;
        while(tmp%(n/i)==0) tmp/=(n/i);
        if(tmp%(n/i)==1) ++ans;
        //if(n%i==0) ans+=2;
        //if(n==i*i) --ans;
    }
    --n;
    for(ll i=2;i*i<=n;++i){
        if(n%i==0) ans+=2;
        if(n==i*i) --ans;
    }
    if(n!=1)++ans;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, k;
    string s;
    cin >> n >> s >> k;
    k--;
    for (int i = 0; i < n; i++)
    {
        if (s[i] != s[k])
            s[i] = '*';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  string ans="APPROVED";
  
  for(int i=0; i<N; i++){
    int A;
    cin >> A;
    if(A%2==0){
      if(A%3!=0 && A%5!=0){
        ans="DENIED";
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// AOJ Volume 1 Problem 0105

#include <stdio.h>
#include <string.h>


typedef struct {
	char word[31];
	int page[1001];
} INDEX;



int main(void)
{
	INDEX index[100];
	char word[31];
	INDEX *index_p[100], *tmp;
	int page;
	int n;
	int i, j;
	int flag;
	
	
	memset(index, 0, sizeof(index));

	for (i = 0; i < 100; i++){
		index_p[i] = &index[i];
	}
	
	n = 0;
	while (scanf("%s%d", word, &page) != EOF){
		for (i = 0; i < n; i++){
			if (strcmp(index_p[i]->word, word) == 0){
				break;
			}
		}
		
		if (i == n){
			strcpy(index_p[n]->word, word);
			n++;
		}
		index_p[i]->page[page] = 1;
	}

	for (i = 0; i < n; i++){
		for (j = 0; j < n - i - 1; j++){
			if (strcmp(index_p[j]->word, index_p[j + 1]->word) > 0){
				tmp = index_p[j];
				index_p[j] = index_p[j + 1];
				index_p[j + 1] = tmp;
			}
		}
	}

	for (i = 0; i < n; i++){
		printf("%s\n", index_p[i]->word);
		flag = 0;
		for (j = 1; j <= 1000; j++){
			if (index_p[i]->page[j] != 0){
				if (flag == 1){
					printf(" ");
				}
				flag = 1;
				printf("%d", j);
			}
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int a = GetInt();
		int b = GetInt();
		int c = GetInt();
		int sum = a + b + c;
		int max = Math.Max(a, Math.Max(b, c));
		Console.WriteLine((max == (sum - max)) ? "Yes" : "No");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

int main()
{
	int N;
	int a;
	int result = 10000;
	cin >> N;
	for(int i = 0;i < N;i++)
	{
		cin >> a;
		int cou = 0;
		while(a % 2 == 0)
		{
			cou++;
			a = a / 2;
		}
		result = min(result , cou);
	}

	cout << result << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}

int main()
{
    int n;
    cin >> n;
    int a[n];
    map<int, int> st;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        st[a[i]]++;
    }
    int ans = n;
    if (st[1] == 1)
    {
        cout << 1;
        return 0;
    }
    if (st[1] > 1)
    {
        cout << 0;
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        if (st[a[i]] >= 2)
        {
            ans--;
            continue;
        }
        for (int j = 2; j * j <= a[i]; j++)
        {

            if (a[i] % j == 0)
            {
                if (st[j] != 0 or st[a[i] / j] != 0)
                {
                    ans--;
                    break;
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 33156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int e[1000][1000];
int main(){
	int N;
	cin>>N;
	rep1(k,10000){
		if(k*(k-1)/2 == N){
			int I = 1;
			rep(i,k) rep(j,i) e[i][j] = e[j][i] = I++;
			puts("Yes");
			cout<<k<<endl;
			rep(i,k){
				cout<<k-1;
				rep(j,k) if(j!=i) cout<<" "<<e[i][j];
				cout<<endl;
			}
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 3072
# -*- coding: utf-8 -*-
#E - Hopscotch Addict
import sys 
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
graph = [[] for _ in range(3*N+1)]
for _ in range(M):
    x,y = map(int,readline().split())
    graph[x].append(y+N)
    graph[x+N].append(y+2*N)
    graph[x+2*N].append(y)
S,G = map(int,readline().split())
dist = [-1]*(N*3+1)
dist[S] = 0
root = S
q = deque([root])

def bfs(q):
    while q:
        x = q.popleft()
        for nx in graph[x]:
            if dist[nx] != -1:
                continue
            dist[nx] = dist[x] + 1
            q.append(nx)
            
bfs(q)
if dist[G] == -1:
    print(-1)
else:
    print(dist[G] // 3)

Measured memory_bytes: 109700
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//void spf(ll num)
//{
//    fore(i,0,num+1)arr[i]=i;
//    for(ll i=2;i<=num;i+=2)
//    {
//        arr[i]=2;
//    }
//    for(ll i=3;i<=num;i+=2)
//    {
//        if(arr[i]==i)
//        for(ll j=i;j<=num;j+=i)
//        {
//           if(arr[j]==j) arr[j]=i;
//        }
//    }
//}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll n;cin>>n;
    string a;
    string b;
    fore(i,0,n)
    {
        ll x;cin>>x;
        a+=to_string(x);
    }
    ll ans=0;
    fore(i,0,n)
       {
           ll x;cin>>x;
           b+=to_string(x);
       }
    if(b>a)
    {
        while(a!=b)
        {
            next_permutation(a.begin(),a.end());
            ans++;
        }
    }
    else
    {
        while(b!=a)
               {
                   next_permutation(b.begin(),b.end());
                   ans++;
                   
               }
    }
    cout<<ans<<endl;
    return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 1000000007;
const i64 INF = 2e15;

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

    int l, r;
    cin >> l >> r;

	if (r / 2019 != (l-1) / 2019) cout << 0 << endl;
	else {
		l %= 2019;
		r %= 2019;

		int ans = 2018;

		REP(i, l, r) {
			REP(j, i+1, r) {
				ans = min(ans, (i*j) % 2019);
			}
		}
		cout << ans << endl;
	}
     
	return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B=LI()
    amari = []
    shortage = 0
    ans=0
    for a,b in zip(A,B):
        if a<b:
            shortage+=b-a
            ans+=1
        else:
            amari.append(a-b)
    if shortage==0:
        print(0)
        return
    amari.sort(reverse=True)
    for a in amari:
        shortage -= a
        ans += 1
        if shortage<=0:
            print(ans)
            return 

    print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18868
#include<iostream>
using namespace std;
int maxnum(int x,int y);
int main(){
    int score[5] = {0};
    int ssub = 0;
    for(int i = 0;i < 5;i++){
        cin >> score[i];
        if(score[i] < 40){
            score[i] = 40;
        }
        ssub+=score[i];
    }

    cout << ssub/5 << endl;
    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// age ye mosh dp ro baze dashti dp tedad baz shodeye baste nashode yadet nare !!
const int N=1e5+100;
ll a[N];
ll n,m,v,p;
ll vis[N];
ll fen[N];
void add(ll idx,ll val){
    for (;idx<N;idx+=idx & (-idx)){
        fen[idx]+=val;
    }
}
ll get(ll idx){
    ll s=0;
    for (;idx;idx-= idx & (-idx)){
        s+=fen[idx];
    }
    return s;
}
ll bs(ll x){
    ll val=a[x];
    val+=m;
    memset(vis,0,sizeof vis);
    memset(fen,0,sizeof fen);
    vector <int> c;
    for (int i=x+1;i<=n;i++){
        if (a[i]>val){
            vis[i]=1;
            c.pb(m);
        }
    }
    ll p1=c.size();
    if (p1>p-1) return 0;
    for (int i=n;i>0;i--){
        if (vis[i] || i==x) continue;
        if (p1<p-1){
            c.pb(m);
           // if (x==3)
            //cout << c.back() << " " << i << endl;

            p1++;
            continue;
        }
        else{
            c.pb(min(m,val-a[i]));
            //if (x==3)
            //cout << c.back() << " " << i << endl;
        }
    }
    ll ans=0;
    for (int i=0;i<c.size();i++){
        ll u=c[i];
        ans+=u;
    }
    if (v==1){
        return 1;
    }
    ans/=(v-1);
    if (ans>=m) return 1;
    return 0;
}
int32_t main(){
    cin >> n >> m >> v >> p;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    ll l=0,r=n+1;
    while(r-l>1){
        ll mid=(r+l)/2;
        ll z=bs(mid);
        if (z==1) r=mid;
        else l=mid;
    }
    cout << n+1-r;
}



Measured memory_bytes: 4576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int main() {
    int A, B;
    cin >> A >> B;
    int cou = 0;
    for (int i = A; i <= B; i++) {
        if (i / 10000 == i % 10 && (i / 1000) % 10 == (i % 100) / 10) {
            cou++;
        }
    }
    cout << cou << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
const int mod=998244353;
int pow(int x, int k)
{
	int ret=1;
	for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ret=(ll)ret*x%mod;
	return ret;
}
const int N=300050;
int F[N],I[N];
int f(int n, int k){ return (ll)F[n]*I[k]%mod*I[n-k]%mod;}
int main()
{
	int n,a,b,i,j;
	ll k;
	scanf("%i %i %i %lld",&n,&a,&b,&k);
	F[0]=1;for(i=1;i<=n;i++) F[i]=(ll)F[i-1]*i%mod;
	I[n]=pow(F[n],mod-2);for(i=n-1;~i;i--) I[i]=(ll)I[i+1]*(i+1)%mod;
	int sol=0;
	for(i=0;i<=n;i++)
	{
		ll sub=(ll)a*i;
		if(sub>k) break;
		if((k-sub)%b) continue;
		j=(k-sub)/b;
		if(j>n) continue;
		sol+=(ll)f(n,i)*f(n,j)%mod;
		if(sol>=mod) sol-=mod;
	}
	printf("%i\n",sol);
	return 0;
}

Measured memory_bytes: 2560
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int A = ni(), B = ni();
		out.println(Math.max(A + B, Math.max(A - B, A * B)));
	}
			    
	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private float nf() {
		return Float.parseFloat(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

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

using namespace std;
using ll = long long;

ll dp[5001][5001];
int end_jmp[5001];

ll res = -1e18;

void set_table(vector<int> &pp, vector<int> &cc, int node);

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

    int n, k;
    cin >> n >> k;

    vector<int> p(n + 1), c(n + 1);

    for (int i = 1; i <= n; ++i)
        cin >> p[i];
    for (int j = 1; j <= n; ++j)
        cin >> c[j];

    for (int s = 1; s <= n; ++s)
        set_table(p, c, s);

    if (k <= 5000)
    {
        for (int i = 1; i <= n; ++i)
            res = max(res, *max_element(&dp[i][1], &dp[i][1] + k));
    }
    else
    {
        for (int i = 1; i <= n; ++i)
        {
            int cycle = end_jmp[i];
            int dv = k / cycle;
            int mod = k % cycle;

            ll a = -1e18, b = -1e18;
            for (int j = 1; j <= mod; ++j)
                a = max(a, dp[i][j]);
            for (int u = 1; u <= cycle; ++u)
                b = max(b, dp[i][u]);
            
            res = max(res, a);
            res = max(res, b);
            res = max(res, a + dv * dp[i][cycle]);
            res = max(res, b + (dv - 1) * dp[i][cycle]);
        }
    }

    cout << res;
}

void set_table(vector<int> &pp, vector<int> &cc, int node)
{
    int curr = pp[node];
    int jmp = 1;

    int remain = 5000;

    while (remain--)
    {
        dp[node][jmp] = dp[node][jmp - 1] + cc[curr];
        ++jmp;
        curr = pp[curr];
    }

    int dest = node;
    curr = pp[node];
    jmp = 1;

    while (curr != dest)
    {
        ++jmp;
        curr = pp[curr];
    }
    end_jmp[node] = jmp;
}

Measured memory_bytes: 199056
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int h[1005];
int main()
{
	int n;scanf("%d",&n);
	int t,a;scanf("%d%d",&t,&a);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	double ans=1e9;int p=0;
	for(int i=1;i<=n;i++)
	{
		double c=(1.0*t-0.006*h[i])-a;c=abs(c);
		if(c<ans) ans=c,p=i;
	}
	printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;
using Grid = vector<vector<bool>>;

bool isRight(int bit, int h, int w, int k, Grid grid){
    bool is = false;
    int cnt = 0;
    Grid tmpg = grid;
    FOR(i, 1, h){
        if (bit & 1 << i-1){//  そのbitが1ならばi行を塗る
            FOR(j, 1, w) tmpg[i][j] = false;
        }
    }
    FOR(i, 1, w){
        if (bit & 1 << i+h-1){//  そのbitが1ならばj列を塗る
            FOR(j, 1, h) tmpg[j][i] = false;
        }
    }
    FOR(i, 1, h){
        FOR(j, 1, w){
            if(tmpg[i][j] == true) cnt ++;
        }
    }
    if(cnt == k) is = true;
    return is;
}

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    char tmp;
    int ans = 0;
    cin >> h >> w >> k;
    Grid grid(h+1, vector<bool>(w+1));

    //初期値を入力
    FOR(i, 1, h){
        FOR(j, 1, w){
            cin >> tmp;
            (tmp == '#')? grid[i][j] = true : grid[i][j] = false;
        }
    }

    //bit full search
    REP(bit, 1 << h+w){
        if(isRight(bit, h, w, k, grid)) ans ++;
    }

    cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;
int64_t gcd(int64_t a, int64_t b)
{
    if (a < b)
    {
        return gcd(b, a);
    }
    else if (a % b == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, a % b);
    }
}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (c % gcd(a, b) == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,w = li()
wv = []
for _ in range(n):
    wv.append(tuple(li()))
    
dp = [[0]*(w+1) for _ in range(n+1)]

for item in range(n):
    wi,vi = wv[item]
    for weight in range(w+1):
        if weight - wi >= 0:
            dp[item+1][weight] = max(dp[item][weight],
                                     dp[item][weight-wi] + vi)
            
        else:
            dp[item+1][weight] = dp[item][weight]
            
            
print(dp[n][w])

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

#define P(x) ((x)*(x));

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

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

    long long ans = LLONG_MAX;
    for(int i = -200;i <= 200;i++){
        long long tmp = 0;
        for(int j = 0;j < n;j++){
            tmp += P(a[j]-i);
        }
        ans = min(tmp, ans);
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace  std;
int main(){
  string s;
  cin >> s;
  vector<char> u;
  int ss = s.size();
  vector<int>t(ss);
  for(int i = 0; i < ss; i++)
    t[i] = (int)(s[i] - 48);


    for(int bit = 0; bit < (1 << ss); bit++){
        int sum = 0;
        u.resize(0);
        for(int i = 0; i < s.size(); i++){
          if(bit & (1 << i))
         {
           sum += t[i];
           u.push_back('+');
         }
         else
         {
           sum -= t[i];
           u.push_back('-');
         }
        }
        if(sum == 7)
        break;
    }
   for(int i = 0; i < 3; i++)
   cout << t[i] << u[i + 1];
   cout << t[3] << "=7" << endl;
      
}

Measured memory_bytes: 256
#include <stdio.h>

int dp[50];

static int fibonacci(int n)
{
    if (n == 0 || n == 1) {
        dp[n] = 1;
    } else if (dp[n] == -1) {
        dp[n] = fibonacci(n - 1) + fibonacci(n - 2);
    }
    
    return dp[n];
}

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

    for (int i = 0; i <= n; i++) {
        dp[i] = -1;
    }

    printf("%d\n", fibonacci(n));
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;

string color(int i){
    if(i < 400)return "GRAY";
    else if(i < 800)return "BROWN";
    else if(i < 1200)return "GREEN";
    else if(i < 1600) return "CYAN";
    else if(i < 2000)return "BLUE";
    else if(i < 2400)return "YELLOW";
    else if(i < 2800)return "ORANGE";
    else if(i < 3200)return "RED";
    else return "FREE";
}

int main() {
    int n;
    cin >> n;
    map<string,int> a;
    rep(i,n){
        int rate;
        cin >> rate;
        a[color(rate)]++;
    }
    if(a.find("FREE") == a.end()){
        cout << a.size() << " " << a.size() << endl;
    }else{
        if(a.size() != 1)cout << a.size()-1 << " " << a.size() -1 + a["FREE"] << endl;
        else cout << a.size() << " " << a["FREE"] << endl;
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
using ll = long long;
using ld = long double;
#define long ll
#define double ld
using namespace std;

const int N = 2e5;
int n;
vector<int> a, s;

int main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		a.push_back(x);
		s.push_back(x);
	}
	sort(all(s));
	int answer = 0;
	for (int i = 0; i < n; ++i) {
		int j = lower_bound(all(s), a[i]) - s.begin();
		answer += (i % 2) != (j % 2);
	}
	assert(answer % 2 == 0);
	answer /= 2;
	cout << answer << "\n";
	return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define orta ((bas+son)/2)
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < ll , ll > ii;

ll n, x, ans, top, b[N], l[N], r[N], u[N], pre[N];
ii a[N];

bool dene(ll X){
	ll mn = 0, ans = 0, kac;
	if(X == x*n){
		kac = n - 1;
		X = x;
	} else{
		kac = X/x;
		X = X%x;
	}
	for(ll i = 1; i <= n; i++){
		int j = a[i].nd;
		ll cvp = 0;
		ll of = l[j];
		mn = (of - l[j])*b[j] - X*of;
		of = r[j];
		mn = min(mn, (of - l[j])*b[j] - X*of);
		if(i <= kac){
			cvp += pre[kac + 1] - a[i].st;
			cvp += mn;
		} else
			cvp = pre[kac] + mn;
		if(cvp == -20765995){
			// cout << kac << " " << i << " " << mn << " " << X << endl;
		}
		ans = min(ans, cvp);
	}
	// cout << X << " " << ans << endl;
	return top + ans <= 0;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld",&n ,&x);
	for(ll i = 1; i <= n; i++){
		scanf("%lld %lld %lld",b + i, l + i, r + i);
		a[i] = mp( (r[i] - l[i])*b[i] - x*r[i], i );
		// cout << a[i].st << " " << a[i].nd << endl;
		top += l[i]*b[i];
	}
	sort(a + 1, a + n + 1);
	// cout << top << endl;
	for(ll i = 1; i <= n; i++){
		pre[i] = pre[i - 1] + a[i].st;
	}

	// cout << ans << " " << top << endl;
	ll bas = 0, son = x*n;
	while(bas < son){
		if(dene(orta))
			son = orta;
		else
			bas = orta + 1;
	}
	// dene(2439);
	printf("%lld\n", orta);

	return 0;
}


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

int main()
{
    bool bingoFlg = false; 

    int bingo[3][3];
    cin >> bingo[0][0] >> bingo[0][1] >> bingo[0][2];
    cin >> bingo[1][0] >> bingo[1][1] >> bingo[1][2];
    cin >> bingo[2][0] >> bingo[2][1] >> bingo[2][2];

    int judge[3][3] = {{0,0,0},
                       {0,0,0},
                       {0,0,0}};

    int N;
    cin >> N;

    int answer[N];

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

    for (int k=0;k<N;k++){
        for (int i=0;i<3;i++){
            for (int j=0;j<3;j++){
                if (bingo[i][j] == answer[k]) judge[i][j] = 1;
            }
        }
    }

    //縦の判定
    for(int i=0;i<3;i++){
        if ( judge[0][i]==1 && judge[1][i]==1 && judge[2][i]==1) bingoFlg=true;
    }
    //横の判定
    for(int i=0;i<3;i++){
        if ( judge[i][0]==1 && judge[i][1]==1 && judge[i][2]==1) bingoFlg=true;
    }
    //斜めの判定
    if ( judge[0][0]==1 && judge[1][1]==1 && judge[2][2]==1) bingoFlg=true;
    if ( judge[2][0]==1 && judge[1][1]==1 && judge[0][2]==1) bingoFlg=true;

    if (bingoFlg) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void)
{
  int n=0;
  char s[200001];
  char t[200001];
  scanf("%s",s);
  scanf("%s",t);

  for(int i=0;i<strlen(s);i++)
  {
    if(s[i]!=t[i]) n++;
  }

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

  return 0;
}

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

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

void main()
{
    long A, B, C;
    scan(A, B, C);
    if (A == 1)
    {
        writeln("YES");
        return;
    }
    foreach (i; 1 .. 10000000)
    {
        long x = A * i % B;
        // writeln(x);
        if (x == C)
        {
            writeln("YES");
            return;
        }
    }
    writeln("NO");
}

/// x^^n % m
T powmod(T = long)(T x, T n, T m = 10 ^^ 9 + 7)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    T tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <queue>
#include <vector>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
const int N=110000;
int A[N],n,K;
int main(){
	scanf("%d%d",&n,&K);
	printf("%d\n",(n-1)/(K-1)+((n-1)%(K-1)>0));
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
            int a, b, c, count = 0,i ;
            string inp = Console.ReadLine();
            string[] data = inp.Split(' ');
            a = int.Parse(data[0]);
            b = int.Parse(data[1]);
            c = int.Parse(data[2]);
            for (i = a; i <= b; i++)
            {
                if (c % i == 0)
                {
                    count++;
                }
            }
            Console.WriteLine("{0}", count);
    }
}


Measured memory_bytes: 9168
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int N;
	bool g=true;
	stack<int> s;
	
	scanf("%d",&N);
	char st[2];
	for(int i=0;i<N;i++){
		scanf("%s",st);
		if(st[0]=='A'){
			s.push(1);
		}
		else{
			if(!s.empty()){
				s.pop();
			}
			else{
				g=false;
				break;
			}
		}
	}
	if(!s.empty())
	g=false;
	if(g!=false)
	printf("YES\n");
	else
	printf("NO\n");
}


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

long long jisu[65];

long long dorec(int x,long long aa, long long bb, long long cc, long long dd){
	//printf("%d %lld %lld %lld %lld\n", x, aa, bb, cc, dd);
	if(x == 0){
		return 1;
	}
	if(cc == -1){
		if((aa & jisu[x-1]) > 0){
			return dorec(x-1, aa - jisu[x-1], bb - jisu[x-1], cc, dd);
		}else if((bb & jisu[x-1]) == 0){
			return dorec(x-1, aa, bb, cc, dd);
		}else{
			if(bb - jisu[x-1] + 1 >= aa){
				return jisu[x-1] + dorec(x-1, aa, jisu[x-1] - 1, -1, -1);
			}else{
				return dorec(x-1, aa, (jisu[x-1] - 1), -1, -1) + dorec(x-1, 0, (bb-jisu[x-1]), aa, (jisu[x-1] - 1));
			}
		}
	}else{
		long long retval = 0;
		if((bb+1) == jisu[x-1]){
			return jisu[x-1] + dorec(x-1, cc - jisu[x-1], dd - jisu[x-1], -1, -1);
		}else if(bb+1 > jisu[x-1]){
			return jisu[x];
		}else if(cc == jisu[x-1]){
			return jisu[x-1] + dorec(x-1, aa, bb, -1, -1);
		}else if(cc < jisu[x-1]){
			return jisu[x-1] + dorec(x-1, aa, bb, cc, jisu[x-1] - 1);	
		}else{
			if(bb + 1 >= cc - jisu[x-1]){
				return (dd - cc + 1) + dorec(x-1, aa, bb, -1, -1);
			}else{
				return (dd - cc + 1) + dorec(x-1, aa, bb, -1, -1);
			}
		}
	}
}

int main(){
	jisu[0] = 1;
	for(int i=1;i<=62;i++) jisu[i] = (jisu[i-1] * 2);
	long long a,b;
	scanf("%lld",&a);
	scanf("%lld",&b);
	/*for(int i=0;i<16;i++){
		for(int j=i;j<16;j++){
			printf("%d %d %lld\n", i,j,dorec(62,i,j,-1,-1));
		}
	}*/
	
	printf("%lld\n",dorec(62,a,b,-1,-1));
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N, M;
  cin >> N >> M;
  vvi C(M, vi(0));
  for(int i = 0; i < N; i++){
    ll A, B;
    cin >> A >> B;
    if(M-A<0) continue;
    C.at(M-A).push_back(B);
  }

  ll ans = 0;
  priority_queue<ll> que;
  for(int i = M-1; i >= 0; i--){
    for(int j = 0; j < C.at(i).size(); j++){
      que.push(C.at(i).at(j));
    }
    int B;
    if(!que.empty()){
      B = que.top();
      que.pop();
    }
    else B = 0;
    ans += B;
  }
  cout << ans << endl;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] S = new int[n];
		String[] strArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			S[i] = Integer.parseInt(strArray[i]);
		}
		
		int q = Integer.parseInt(br.readLine());
		int[] T = new int[q];
		strArray = br.readLine().split(" ");
		for(int i = 0; i < q; i++){
			T[i] = Integer.parseInt(strArray[i]);
		}		
		
		int count = 0;
		for(int i = 0; i < T.length ; i++){
			//if(linearSearch(S, T[i]) != -1){
			if(binarySearch(S, T[i]) != -1){
				count++;
			}
		}
		System.out.println(count);
	}
	
	static int linearSearch (int[] array , int key){
		int result = -1;
		
		for(int i = 0; i < array.length ;i++){
			if(array[i] == key){
				return i;
			}
		}
		
		return result;
	}
	
	static int binarySearch(int[] array, int key){
		int left = 0;
		int right = array.length;
		int mid;
		
		while(left < right){
			mid = (left + right) / 2;
			if(array[mid] == key){
				return mid;
			}
			else if(key < array[mid]){
				right = mid;
			}
			else {
				left = mid + 1;
			}
		}
		
		return -1;
	}

}

Measured memory_bytes: 47452
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    let mut ans = 0;
    let s = s.chars().collect::<Vec<char>>();
    for i in 0..3 {
        if ans >= 1 {
            if s[i-1] == 'S' {
                continue;
            } else if s[i] == 'R' {
                ans += 1;
            }
        } else {
            if s[i] == 'R' {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2132