akhauriyash/Code-Regression huggingface dataset:
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  int A, B, C;
  cin >> A >> B >> C;

  REP(i, B) {
    if (A * i % B == C) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	int n, m;
	vector<int> a[300];
	int b[300];//各人の参加スポーツ
	int c[301] = {};//各人の参加スポーツ
	bool flug[301];
	int answer;
	for (int i = 0; i < 301; i++) {
		flug[i] = true;
	}


	cin >>n >> m;

	for (int i = 0; i < n; i++) {
		a[i].resize(m+1);
	}

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

	//各人の参加スポーツb[i]と各スポーツの参加人数c[i]の最大値maxnum
	for (int i = 0; i < n; i++) {
		b[i] = a[i][0];
		c[b[i]] ++;
	}
	int maxnum = 0;
	for (int i = 1; i <= m; i++) {
		maxnum = max(c[i], maxnum);
	}
	answer = maxnum;

	for (int k = 1; k <= m-1; k++) {
		//一番参加人数が多いスポーツを不開催にしていく
		
		int temp;
		maxnum = 0;
		for (int i = 1; i <= m; i++) {
			if (c[i] > maxnum) {
				temp = i;
				maxnum = c[i];
			}
		}
		flug[temp] = false;

		//flugを元に各人の参加スポーツb[i]を決定

		for (int i = 0; i <= m; i++) {
			c[i] = 0;
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (flug[a[i][j]]) {
					b[i] = a[i][j];
					c[b[i]]++;
					break;
				}
			}
		}

		int maxnum = 0;
		for (int i = 1; i <= m; i++) {
			maxnum = max(c[i], maxnum);
		}
		answer = min(answer, maxnum);
		
		//もうゲームを削っても最大参加人数が減らない	
		if (answer <= n / (m - k)) {
			break;
		}
	}

	cout << answer;




	return 0;
}

Measured memory_bytes: 640
let f s =
  let g = Str.split (Str.regexp " ") s
            |> List.map int_of_string
            |> Array.of_list
  in
  (g.(0)*3600 + g.(1)*60 + g.(2), g.(3)*3600 + g.(4)*60 + g.(5))
;;

let print time =
  Printf.printf "%d %d %d\n" (time/3600) ((time/60) mod 60) (time mod 60)

let () =
  let (a1, a2) = read_line () |> f and
      (b1, b2) = read_line () |> f and
      (c1, c2) = read_line () |> f in
  print (a2-a1);print (b2-b1);print (c2-c1)
;;

Measured memory_bytes: 2276
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define ll long long
#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define MOD 1000000007
using namespace std;

int main(){
	fast_io;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll cnt=b-a+1;
	ll c1=0,c2=0,c3=0;
	a--;
	ll x = (c*d)/__gcd(c,d);
	c1 = (b/c) - (a/c);
	c2 = (b/d) - (a/d);
	c3 = (b/x) - (a/x);
	cnt = cnt-(c1+c2-c3);
	cout<<cnt;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int M, D;
	cin >> M >> D;

	int ans = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 10; j <= D; j++) {
			if (j / 10 < 2 || j % 10 < 2) continue;
			if (i == (j / 10) * (j % 10)) ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i;
  int n;
  int home_number;
  int min, max;

  scanf("%d", &n);

  scanf("%d", &home_number);

  min = home_number;
  max = home_number;

  for (i = 1; i < n; i++) {
    scanf("%d", &home_number);
    if (home_number < min) {
      min = home_number;
    } else if (home_number > max) {
      max = home_number;
    }
  }

  printf("%d\n", (max - min + 1) / 2);

  return 0;
}

  



Measured memory_bytes: 2100
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($a,$b) = explode(" ",trim(fgets(STDIN)));
$P = explode(" ",trim(fgets(STDIN)));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

//じぶんより小さいのが左側にあったらダメ？
$ret=1;
$min = $P[0];
for($i=1;$i<$N;$i++) {
  if ($min >= $P[$i]) {
    $ret++;
  }
  $min = min($min,$P[$i]);
}
printf("%d\n",$ret);


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

const int MAX_N = 100100;
const ll MOD = 1e9+7;

ll pMOD( ll a, ll p ){ 
  // aのp乗数をMODで返す
  
  if( p == 0 ){ return 1LL;}
  else if( p == 1 ){ return a;}
  else{
    
    if( p % 2 == 0 ){ return ( pMOD(a,p/2)*pMOD(a,p/2) ) % MOD;}
    else{
      return ( a * ( ( pMOD( a, (p-1)/2 ) * pMOD( a, (p-1)/2 ) )%MOD ) ) % MOD;
    }
    
  }
}

int main(){ 
  
  ll N; cin >> N;
  ll x[MAX_N];
  
  for(ll i = 1; i <= N; i++){ cin >> x[i];}
  
  ll ex = 1LL;
  
  for(ll i = 1; i < N; i++){ ex *= i; ex %= MOD;}
  
  // exは(N-1)! % MOD
  
  ll b[MAX_N];
  
  b[1] = ex;
  
  for(ll i = 1; i+1 < N; i++){ 
    
    b[i+1] = b[i]+ex*pMOD( i+1, MOD-2 );
    
    b[i+1] %= MOD;
    
  }
  
  ll ans = 0;
  
  for(ll i = 1; i < N; i++){ 
    
    ans += (x[i+1]-x[i]) * b[i];
    
    ans %= MOD;
    
  }
  
  
  cout << ans << endl;
  
  return 0;
} 
  
  

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60;
const ll mod=1e9+7;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1};

vector<int> v[101010];
int n,dp[2][101010];
int dfs(int k,int x,int par){
    if(dp[x][k]!=0)return dp[x][k];
    int ret=0;
    if(x==1){
        ret=1;
        for(auto e:v[k])if(e!=par)ret+=min(dfs(e,1,k),dfs(e,0,k));
    }
    else for(auto e:v[k])if(e!=par)ret+=dfs(e,1,k);
    return dp[x][k]=ret;
}
int main(){
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int ans=min(dfs(0,1,-1),dfs(0,0,-1));
    if(2*ans<n)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i;
    int a,b;
    for(i=1;;i++){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0)break;
        if(a>b){
            printf("%d %d\n",b,a);
        }else{
            printf("%d %d\n",a,b);
        }
    }
    
    return 0;
}



Measured memory_bytes: 1976
import java.util.*;

class Main{
    static long mod = 1000000007;
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int N= sc.nextInt();
        int K= sc.nextInt();
        int result = 0;
        if(K!=1){
            result = N-K;
        }
        System.out.println(result);
    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int a,b;
    cin >> a >> b;

    if(a>9 || b>9)
        cout << -1 << endl;
        else
        cout << a*b <<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
double pi = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,r,T,cas=0;
    cin>>r;
    cout<<pi*r*2;
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const int INF = 1001001001;

void fcgrp(const vector<string> &s, vector<vector<int>> &grp, int si, int sj, int num){
  int h = s.size(), w = grp.front().size();
  int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};
  queue<pair<int, int>> q;
  q.push({si, sj});
  grp.at(si).at(sj) = num;
  while(!q.empty()){
    auto [i, j] = q.front(); q.pop();
    rep(k, 4){
      int ni = i + di[k], nj = j + dj[k];
      if(nj < 0 || w <= nj || ni < 0 || h <= ni) continue;
      if(grp.at(ni).at(nj) != -1 || s.at(ni).at(nj) == '#') continue;
      grp.at(ni).at(nj) = num;
      q.push({ni, nj});
    }
  }
}

void make_grh(const vector<string> &s, const vector<vector<int>> &grp, vector<set<int>> &grh, int si, int sj){
  int now = grp.at(si).at(sj);
  int h = s.size(), w = s.front().size();
  rep2(i, -2, 3){
    rep2(j, -2, 3){
      int ni = i + si, nj = j + sj;
      if(nj < 0 || w <= nj || ni < 0 || h <= ni) continue;
      int nx = grp.at(ni).at(nj);
      if(nx == now || s.at(ni).at(nj) == '#') continue;
      grh.at(now).insert(nx);
      grh.at(nx).insert(now);
    }
  }
}

int main(){
  int h, w;
  cin >> h >> w;
  int ch, cw;
  cin >> ch >> cw;
  ch--; cw--;
  int dh, dw;
  cin >> dh >> dw;
  dh--; dw--;
  vector<string> s(h);
  rep(i, h) cin >> s.at(i);
  vector<vector<int>> grp(h, vector<int>(w, -1));
  int num = 0;
  rep(i, h)rep(j, w){
    if(s.at(i).at(j) == '.' && grp.at(i).at(j) == -1){
      fcgrp(s, grp, i, j, num);
      num++;
    }
  }
  vector<set<int>> grh(num, set<int>());
  rep(i, h)rep(j, w){
    if(s.at(i).at(j) == '#') continue;
    make_grh(s, grp, grh, i, j);
  }
  int st = grp.at(ch).at(cw), gt = grp.at(dh).at(dw);
  vector<int> d(num, INF);
  queue<int> q;
  q.push(st);
  d.at(st) = 0;
  while(!q.empty()){
    int now = q.front(); q.pop();
    for(auto i : grh.at(now)){
      if(d.at(i) != INF) continue;
      d.at(i) = d.at(now) + 1;
      q.push(i);
    }
  }
  int ans = d.at(gt);
  if(ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 33764
use proconio::{input, fastout};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        ss: [String; n],
    }

    let judges = vec!["AC".to_string(), "WA".to_string(), "TLE".to_string(), "RE".to_string()];

    let mut hm = HashMap::new();

    for judge in judges.iter() {
        hm.insert(judge.clone(), 0);
    }

    for s in ss {
        *hm.entry(s).or_insert(0) += 1;
    }

    for judge in judges.iter() {
        if let Some(num) = hm.get(judge) {
            println!("{} x {}", judge, num);
        }
    }
}


Measured memory_bytes: 7868
#include <iostream>
using namespace std;
int main(){
  int x, y;
  char n;
  bool a[4][13] = {};
  cin >> x;
  for(int i=0; i<x; i++){
    cin >> n >> y;
  switch (n) {
    case 'S': a[0][y-1] = true;
      break;
    case 'H': a[1][y-1] = true;
      break;
    case 'C': a[2][y-1] = true;
      break;
    case 'D': a[3][y-1] = true;
      break;
   }
  }
  for(int j=0; j<4; j++){
   for(int t=0; t<13; t++){
    if(!a[j][t]){
      switch(j){
        case 0: cout << 'S' << ' ' << t+1 << endl;
         break;
        case 1: cout << 'H' << ' ' << t+1 << endl;
         break;
        case 2: cout << 'C' << ' ' << t+1 << endl;
         break;
        case 3: cout << 'D' << ' ' << t+1 << endl;
         break;
      }
    }
   }
  }
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  for(int i=0; i<m; i++) {
    cin >> l.at(i) >> r.at(i);
  }
  
  int L = l.at(0);
  int R = r.at(0);
  
  for(int i=0; i<m; i++) {
    L = max(L, l.at(i));
    R = min(R, r.at(i));
  }
  if(R >= L) {
    cout << R - L + 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

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

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

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

   dp[0] = 0;
   for(int i=1;i<n;i++){
   	   dp[i] = INT_MAX;
   	   for(int j=1;j<=k && i>=j;j++)
   	   	  dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]));
   }
   
   cout<<dp[n-1];

return 0;	
}

Measured memory_bytes: 1024
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
const int inf=INT64_MAX;
int dp[100005][3];
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0)
    {
        if((double)ans>=sqrt((double)inf)) return 0;
        return (ans*ans);
    }
    if((double)ans>=sqrt((double)(inf/x))) return 0;
    return x*ans*ans;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    // cin>>t;
    // int tmp=t;
    while(t--)
    {
        int n;
        cin>>n;
        int h[n];
        for(int i=0;i<n;i++) cin>>h[i];
        int ans[100005]={0};
        ans[1]=abs(h[1]-h[0]);
        for(int i=2;i<n;i++) ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2] +abs(h[i]-h[i-2]));
        cout<<ans[n-1]<<"\n";
    }
}


Measured memory_bytes: 5192
#include <stdio.h>

int main(void)
{
  int b=0;
  char n[10];

  fgets(n, sizeof(n), stdin);

  for (int i=0; n[i] != '\n'; i++) {
    if (n[i] == '1') {
      b++;
    }

  }

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

  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
using namespace std;
char s[3];
int a,b,c;
int main()
{
    scanf("%s",s);
    for(int i=0;i<=2;i++)
    {
        if(s[i]=='a') a++;
        if(s[i]=='b') b++;
        if(s[i]=='c') c++;
    }
  if(a==1&&b==1&&c==1) printf("Yes"); else printf("No");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep (i ,n) for(int i=0;i<(n);i++) 
ll gcd (ll a,ll b) {return b?gcd(b,a%b):a;}   
ll lcm (ll a,ll b) {return a/gcd(a,b)*b;} 
const int mod=1e9+7;
int main(){
		int64_t n,a,b,c,d,e;
		cin>>n>>a>>b>>c>>d>>e;
		cout<<(n-1)/min({a,b,c,d,e})+5<<endl;
		return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class B
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var p = read();
		int n = h[0], k = h[1];

		var smin = Slide(p, k + 1, (x, y) => x <= y);
		var smax = Slide(p, k + 1, (x, y) => x >= y);
		var c = n - k + 1 - Enumerable.Range(0, n - k).Count(i => smin[i] == p[i] && smax[i] == p[i + k]);

		int c2 = 0, t = 1;
		for (int i = 1; i < n; i++)
		{
			if (p[i] > p[i - 1]) t++;
			else
			{
				if (t >= k) c2++;
				t = 1;
			}
		}
		if (t >= k) c2++;

		Console.WriteLine(c - Math.Max(c2 - 1, 0));
	}

	static int[] Slide(int[] a, int k, Func<int, int, bool> c)
	{
		var r = new int[a.Length - k + 1];
		var q = new int[a.Length];
		for (int i = 1 - k, j = 0, s = 0, t = -1; j < a.Length; i++, j++)
		{
			while (s <= t && c(a[j], a[q[t]])) t--;
			q[++t] = j;
			if (i < 0) continue;
			r[i] = a[q[s]];
			if (q[s] == i) s++;
		}
		return r;
	}
}


Measured memory_bytes: 35268
#!/usr/bin/env python3
_, c, k, *t = map(int, open(0).read().split())
t.sort()
n = 0
f = t.pop(0)
p = 1
for i in t:
    if i > f + k or p >= c:
        n += 1
        p = 1
        f = i
    else:
        p += 1
print(n + (c > 0))


Measured memory_bytes: 19968
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = new char[s.length()];
        for(int i = 0; i < s.length(); i++){
            c[i] = s.charAt(i);
        }
        for(int i = 0; i < s.length(); i+=2){
            System.out.print(c[i]);
        }
    }
}

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

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);
  vector<vector<int>> avi(n,vector<int>(m));
  rep(i,n){
    int C;
    cin>>C;
    c[i]=C;
    rep(j,m){
      int a;
      cin>>a;
      avi[i][j]=a;
    }
  }

  int min_cost = 1200010;
  bool ch = false;
  for(int tmp=0; tmp<(1<<n); tmp++){ //全探索
    bitset<12> b(tmp);
    int tmp_cost = 0;
    vector<int> tmp_avi(m,0);
    //金額と、能力上昇値の計算始まり
    rep(i,n){ 
      if(b.test(i)){
        tmp_cost+=c[i];
        rep(j,m){
          tmp_avi[j]+=avi[i][j];
        }
      }
    } 
    //金額と、能力上昇値の計算終わり
    bool suc =true;
    rep(i,m){
      if(tmp_avi[i]<x){
        suc = false;
      }
    }
    if(suc){
      min_cost=min(min_cost,tmp_cost);
      ch = true;
    }
  }

  if(ch){
    cout<<min_cost<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3536
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

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

typedef long long ll;
typedef string str;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	int k;
	string s;
	cin >> k;
	cin >> s;
	int n = s.size();
	if(k >= n){
		cout << s;
	}
	else{
		for(int i = 0; i < k; i++){
			cout << s[i];
		}
		cout << "...";
	}

}


Measured memory_bytes: 3624
M,s=998244353,0
d=[1]+[0]*7**6
e=d[:]
for _ in'_'*input():
 a=input();s+=a;i=s
 while~i:d[i]+=d[i-a]*2%M;e[i]+=e[i-a]%M;i-=1
print(sum(d)+~s%2*e[s/2]*3-3*sum(d[:s/2+1]))%M

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int main() {
	cin >> n;
	
	bool ans = false;
	inc(i, n) {
		string s;
		cin >> s;
		if(s == "Y") { ans = true; }
	}
	
	cout << (ans ? "Four" : "Three") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

vector <int> vec[SIZE];
bool use[SIZE];
int dep[SIZE];
int deg[SIZE];

void dfs(int v=0,int p=-1,int d=0)
{
	use[v]=true;
	dep[v]=d;
	for(int i=0;i<vec[v].size();i++)
	{
		int to=vec[v][i];
		if(to!=p)
		{
			if(!use[to]) dfs(to,v,d+1);
			else if(dep[to]<dep[v])
			{
				printf("%d %d\n",v+1,to+1);
				deg[v]++;
			}
		}
	}
	if(p!=-1)
	{
		if(deg[v]%2==1)
		{
			printf("%d %d\n",v+1,p+1);
			deg[v]++;
		}
		else
		{
			printf("%d %d\n",p+1,v+1);
			deg[p]++;
		}
	}
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	if(m%2==1)
	{
		puts("-1");
		return 0;
	}
	dfs();
	return 0;
}


Measured memory_bytes: 15488
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]

ans = 0
for i in range(N):
    candies = 0
    for j in range(N):
        if j < i:
            candies += A[0][j]
        elif j == i:
            candies += A[0][j]
            candies += A[1][j]
        elif i < j:
            candies += A[1][j]
    ans = max(ans, candies)
print(ans)
    

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    
    int keta;
    
    scanf("%d\n",&N);
    
    if(N < 10){
        printf("%d\n",N);
    }
    else if(N<100){
        printf("9\n");
    }
    else if(N<1000){
        printf("%d\n",N-99+9);
    }
    else if(N<10000){
        printf("909\n");
    }
    else if(N<100000){
        printf("%d\n",N-9999+909);
    }
    else{
        printf("90909\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
#include <functional>
#include <string.h>
#include <iomanip>
#include <complex>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 
typedef double db;

const int mod=1e9+7;
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
#define MP make_pair
#define FF first
#define SS second
#define LB lower_bound
#define UB upper_bound
#define PB push_back
#define lc ((p<<1)+1)
#define rc ((p<<1)+2)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define all(v) (v).begin(),(v).end()
#define clean(v,a) memset(v,a,sizeof(v))
#define PQ priority_queue

/*
 * high precision: printf("%.12lf",(db)ans);
 *
 * clear output buffer: fflush(stdout);
 *
 * sync off: ios::sync_with_stdio(false);
 *
 */

const int Maxn=1e5+5;

int n;
int a[Maxn];
int b[Maxn];
int num[Maxn<<1];

bool check(int x)
{
	for(int i=1;i<=n;i++)
	{
		b[i]=a[i]>=x?1:-1;
	}
	ll ans0=0,ans1=0;
	int cnt0=0,cnt1=0;
	for(int i=1,cur=0;i<=n;i++)
	{
		cur+=b[i];
		num[cur+Maxn]++;
		if(cur>=0) cnt1++;
		else cnt0++;
	}
	for(int i=1,cur=0;i<=n;i++)
	{
		ans0+=cnt0;
		ans1+=cnt1;
		if(b[i]>0)
		{
			cnt1-=num[cur+Maxn]+1;
			cnt0+=num[cur+Maxn];
			cur++;
		}
		else
		{
			cur--;
			cnt1+=num[cur+Maxn]-1;
			cnt0-=num[cur+Maxn];
		}
		num[cur+Maxn]--;
	}
	return ans1>=ans0;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	int lb=1,ub=1e9+1,mi;
	while(ub-lb>1)
	{
		mi=(ub+lb)>>1;
		if(check(mi)) lb=mi;
		else ub=mi;
	}
	printf("%d\n",lb);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<string> list(100);
  int H,W;
  cin >> H >> W;
  for(int i=0;i<H;i++) cin >> list.at(i);
  
  for(int i=0;i<W+2;i++) cout << "#";
  cout << endl;
  for(int i=0;i<H;i++) cout << "#" << list.at(i) << "#" << endl;
  for(int i=0;i<W+2;i++) cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, m;
vector<int> et[100000];

signed main() {
	int i, j;
	
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	
	queue<int> que;
	static int dist[100000];
	rep(i, n) dist[i] = -1;
	
	que.push(0);
	dist[0] = 0;
	
	while(!que.empty()) {
		int v = que.front(); que.pop();
		rep(i, et[v].size()) {
			int nv = et[v][i];
			if (dist[nv] == -1) {
				dist[nv] = dist[v] + 1;
				que.push(nv);
			}
		}
	}
	
	cout << "Yes" << endl;
	for (i = 1; i < n; i++) {
		rep(j, et[i].size()) {
			int nv = et[i][j];
			if (dist[i] == dist[nv] + 1) {
				cout << nv + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();

        System.out.println(x < a ? 0 : 10);

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	if(n>=1&&n<=9&&m>=1&&m<=9)printf("%d\n",n*m);
	else puts("-1");
	return 0;
}


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

ll N;

void solve() {
    cin >> N;
    vector<ll> A;

    for (ll a = 1; a * a <= N; ++a) {
        if (N % a == 0) {
            A.push_back(a);
            if (a * a != N) {
                A.push_back(N/a);
            }
        }
    }

    ll ans = 0;

    for (auto a: A) {
        ll b = (N - a) / a;
        if (b > a)
            ans += b;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 384
h,w,d=map(int,input().split())
l=[list(map(int,input().split())) for i in range(h)]
L=[0 for i in range(h*w)]
for i in range(h):
  for j in range(w):
    L[l[i][j]-1]=[i,j]

sumL=[0 for i in range(h*w+1)]
for i in range(h*w):
  if i>=d:
    sumL[i+1]=sumL[i+1-d]+abs(L[i][0]-L[i-d][0])+abs(L[i][1]-L[i-d][1])

q=int(input())
QL=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  print(sumL[QL[i][1]]-sumL[QL[i][0]])

Measured memory_bytes: 45080
import sys
A,B,C = map(int,input().split())
if not ( 1 <= B <= 20 and B <= A <= 20 ): sys.exit()
if not ( 1 <= C <= 20 ): sys.exit()

res =  C - (A - B)
print(res) if res >= 0 else print(0) 

Measured memory_bytes: 9172
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll inq(ll x, ll y, ll mod)
{
    if (y == 0) return 1;
    ll l = inq(x, y / 2, mod);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

ll rev(ll x, ll mod)
{
    return inq(x, mod - 2, mod);
}

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

ll a[50000];
ll blocked[50000];

int ans = 1e9 + 1;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, k, q;
    cin >> n >> k >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    vector<pii> v;
    for (int i = 1; i <= n; i++) v.push_back({a[i], i});
    sort(all(v));
    blocked[0] = 1;
    blocked[n + 1] = 1;
    ll last_checked = 0;
    for (int j = 0; j < n; j++)
    {
        if (v[j].first != last_checked)
        {
            vector<int> r;
            for (int i = 1; i <= n + 1; i++)
            {
                int ii = i;
                vector<int> s;
                while (blocked[ii] == 0)
                {
                    s.push_back(a[ii]);
                    ii++;
                }
                sort(all(s));
                for (int ii = 0; ii < (int)s.size() - k + 1; ii++)
                {
                    r.push_back(s[ii]);
                }
                i = ii;
            }
            sort(all(r));
            //F(i, r.size()) cout << r[i] << " ";
            //cout << endl;
            if (r.size() >= q)
            {
                ans = min(ans, r[q - 1] - r[0]);
            }
            last_checked = v[j].first;
        }
        blocked[v[j].second] = 1;
    }
    cout << ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
	LL a, b, c; cin >> a >> b >> c;
	if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	long long ans=0,a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		a[i] -= i;
	} 
	sort(a,a+n);
	for(int i=0;i<n;i++)
		ans += abs(a[n/2]-a[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
n, m = map(int, input().split())

x = list(map(int, input().split()))

gap = []


if( n >= m):
    print(0)
    exit()
else:
    x = sorted(x)
    for i in range(m-1):
        gap.append(x[i+1] - x[i])
    gaps = sorted(gap)

print(sum(gaps[:m-n]))


Measured memory_bytes: 58408
N = int(input())
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
result = True

for i in range(N):
    dt = txy[i + 1][0] - txy[i][0]
    dist = abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])
    
    if(dist > dt): result = False
    if(dist % 2 != dt % 2): result = False

print(("No", "Yes")[result])

Measured memory_bytes: 28148
// Problem : Q - Flowers
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_q
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e15
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 200005

//Solution

int n;
int a[N],h[N],dp[N];

class SegTree{
    int tl,tr,sum;
    SegTree *left, *right;
    
    public:
    
    SegTree(int l, int r){
        sum = 0;
        tl = l;
        tr = r;
        left = nullptr;
        right = nullptr;
    }
    
    void makeChildren(){
        int tm = (tl+tr)/2;
        left = new SegTree(tl,tm);
        right = new SegTree(tm+1,tr);
    }
    
    void update(int pos, int val){
        sum = max(sum,val);
        if(tl == tr) return;
        if(left == nullptr) makeChildren();
        if(pos <= left->tr) left->update(pos,val);
        else right->update(pos,val);
    }
    
    int get(int l, int r){
        if(l > tr || r < tl) return 0;
        if(tl >= l && tr <= r) return sum;
        if(left == nullptr) return 0;
        return max(left->get(l,r),right->get(l,r));
    }
};

void solve(){
    cin>>n;
    SegTree *st = new SegTree(1,n);
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        int best = st->get(1,h[i]-1);
        dp[i] = best + a[i];
        st->update(h[i],dp[i]);
    }
    int ans = 0;
    for(int i=0;i<n;i++) ans = max(ans,dp[i]);
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 27152
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;
const int INF = 1001001001;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        if(a[i] % 2 != 0){
            cout << "first\n";
            return 0;
        }
    }
    cout << "second\n";
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    ans_tmp = min(A[i],B[i])
    ans += ans_tmp
    A[i] = A[i] - ans_tmp
    B[i] = B[i] - ans_tmp
    ans_tmp = min(A[i+1],B[i])
    ans += ans_tmp
    A[i+1] = A[i+1] - ans_tmp
    B[i] = B[i] - ans_tmp
print(ans)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
#define double long double
using namespace std;

const double INF = 1e9;
const double EPS = 1e-11;

// ????¬????
struct P3{
  double x,y,z;
  double vx,vy,vz;
  double r,vr;
  P3(double x=0, double y=0, double z=0):x(x),y(y),z(z){}
  P3 operator + (const P3 &a) const{ return P3(x+a.x, y+a.y, z+a.z); }
  P3 operator - (const P3 &a) const{ return P3(x-a.x, y-a.y, z-a.z); }
  P3 operator * (const double &c) const{ return P3(x*c, y*c, z*c); }
  void input(){cin>>x>>y>>z>>vx>>vy>>vz>>r>>vr;}
  P3 v ()const{return P3(vx,vy,vz);}
};
P3 operator * (double c, const P3 &a){ return P3(c * a.x, c * a.y, c * a.z); }


double norm(P3 a){ return a.x*a.x + a.y*a.y + a.z*a.z; }
double abs(P3 a){ return sqrt(norm(a)); }

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

double calc(P3 A,P3 B,double t){
  if((A.r-t*A.vr)<0|| (B.r-t*B.vr)<0) return -1;
  return abs((A+t*A.v())-(B+t*B.v())) - ((A.r-t*A.vr) + (B.r-t*B.vr));
}

double calc(P3 A,P3 B){
  double L=0,R=INF,cnt = 64;
  while(cnt--){
    double M = (L+R)/2;
    double y1 = calc(A,B,M);
    double y2 = calc(A,B,M+EPS);
    if(y1<0||y1-y2<0) R = M;
    else L = M+EPS;
  }
  return L;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<P3>A(n);
    for(int i=0;i<n;i++) A[i].input();

    priority_queue<PP,vector<PP>,greater<PP> >Q;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	double t = calc(A[i],A[j]);
	if(abs(calc(A[i],A[j],t))<2e-8)Q.push(PP(t,P(i,j)));
      }

    vector<double> ans(n,-1);
    while(!Q.empty()){
      PP t = Q.top();Q.pop();
      double c = t.first;
      int a = t.second.first;
      int b = t.second.second;
      if(ans[a]>=0||ans[b]>=0)continue;
      ans[a] = ans[b] = c;
    }

    for(int i=0;i<n;i++){
      if(ans[i]<0) ans[i] = A[i].r / A[i].vr;
      ans[i] = min(ans[i],A[i].r / A[i].vr);
      printf("%.10Lf\n",ans[i]);
    }    
    
  }
  return 0;    
}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readS(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readS(String str) {
		if (N >= 3200)
			System.out.println(str);
		else
			System.out.println("red");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 23380
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print((n-(n>>1))/n)
    return

#B
def B():
    n,k = LI()
    h = LI()
    ans = 0
    for i in h:
        if i >= k:
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    a = LI()
    b = [(a[i],i+1) for i in range(n)]
    b.sort()
    ans = [b[i][1] for i in range(n)]
    print(*ans)
    return

#D
def D():
    def divisor(n):
        if n < 4:
            return set([n])
        res = set([1])
        i = 2
        m = n
        while i**2 <= n:
            if m%i == 0:
                while m%i == 0:
                    m //= i
                res.add(i)
            i += 1
        res.add(m)
        return res
    a,b = LI()
    if min(a,b) == 1:
        print(1)
        return
    s = divisor(a)
    t = divisor(b)
    s &= t
    print(len(s))
    return

#E
def E():
    n,m = LI()
    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 39280
#include <stdio.h>

int main(){
  int n;
  if(scanf("%d",&n)==1){}
  int h[n];int i;
  for(i=0;i<n;i++){
    if(scanf("%d",&h[i])==1){}
  }
  int max=0;int tmp=0;
  for(i=0;i<n-1;i++){
    if(h[i]>=h[i+1]){
      tmp++;
      if(max<tmp){
        max=tmp;
      }
    }else{
      tmp=0;
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

P f(int x) {
    int a = x % 10;
    int b = 0;
    while(x) {
        b = x;
        x /= 10;
    }
    return P(a, b);
}

int main() {
    int n;
    cin >> n;
    map<P, int> freq;
    for(int i = 1; i <= n; i++) {
        P p = f(i);
        freq[p]++;
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        P p = f(i);
        P q(p.second, p.first);
        ans += freq[q];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  int temp=0;
  cin >> N >> A;
  for(int i=0;i<=20;i++){
  	if (N - 500 * i <= A && N - 500 * i >= 0) {
 	   cout << "Yes"  << endl;
       temp=1;
       break;
 	 }
  }
  if(temp==0){
    cout << "No"  << endl;
  }
}

Measured memory_bytes: 256
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
c = [list(map(int, input().split())) for i in range(N)]

G1 = [0]*C
G2 = [0]*C
G3 = [0]*C
a = int(0)

for i in range(N):
    for j in range(N):
        if (i + j) % 3 ==2:
            G1[c[i][j]-1] += 1
        elif (i + j) % 3 == 0:
            G2[c[i][j]-1] += 1
        else:
            G3[c[i][j]-1] += 1
ans_candi = []


for i1 in range(C):
    for i2 in range(C):
        for i3 in range(C):
            t = int(0)
            if i1!=i2 and i2!=i3 and i3!=i1:
                for j in range(C):
                    t += D[j][i1]*G1[j]
                for j in range(C):
                    t += D[j][i2]*G2[j]
                for j in range(C):
                    t += D[j][i3]*G3[j]
                ans_candi.append(t)

print(min(ans_candi))

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

int main(int argc, char **argv)
{
	ll a, b, c, d; cin >> a >> b >> c >> d;

	bool t{true};

	while (1)
	{
		if (t)
			c -= b;
		else
			a -= d;

		if (a <=  0 || c <= 0) break;
		t ^= true;
	}
	std::cout << (t ? "Yes" : "No")<< std::endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;

int main(){
    
    long a, b, c, k;
    cin >> a >> b >> c >> k;
    
    if(k <= a){
        cout << k << "\n";
        return 0;
    } else if(k <= a + b){
        cout << a << "\n";
        return 0;
    } else {
        cout << (2 * a - k + b) << "\n";
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 3168
/**
 * PrintFrame.cpp
 * Create:20180420
 * Description:複数のH,Wのリストを読み込み、
 * その分の四角形の枠を表示する。
 * 四角形は一辺を"#"で表し、中身を"."で表す。
 */
#include <iostream>
#include <vector>

/**
 * 長方形クラス
 * @param height 高さ
 * @param width  幅
 */
class Rectangle {
private:
  int width;
  int height;
public:
  /**
   * コンストラクタ
   * @param width  横幅
   * @param height 縦幅
   */
  Rectangle(int height, int width){
    this->width = width;
    this->height = height;
  }

  /**
   * 描写
   */
  void draw(){
    for(int i = 0; i < height; i++) {
      if (i == 0 || i == height - 1){
        for (int j = 0; j < width; j++) {
          std::cout << "#";
        }
      } else {
        for (int j = 0; j < width; j++) {
          if (j == 0 || j == width - 1) {
            std::cout << "#";
          } else {
            std::cout << ".";
          }
        }
      }
      std::cout << std::endl;
    }
  }
};

int main(int argc, char* argv[]){
  std::vector<Rectangle> vec;
  int h, w;

  while (true){
    std::cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    Rectangle r = Rectangle(h, w);
    vec.push_back(r);
  }

  for(Rectangle r: vec){
    r.draw();
    std::cout << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 500000;
const int MOD = 1e9 + 7;
int n;
int x[N], a, b;

signed main()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n >> a >> b;
    ll ans = 0;
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 1; i < n; i++)
    {
        int d = x[i] - x[i - 1];
        ans += min(1ll * d * a, 1ll * b);
    }
    cout << ans;
}


Measured memory_bytes: 640