akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int D, c[30], s[400][30];
int ans[400];
int tans[400];

// 乱数
unsigned int xor32() {
  static unsigned int x = 2463534242;
  x = x ^ (x << 13); x = x ^ (x >> 17);
  return x = x ^ (x << 15);
}

int val(){
  int last[30];
  REP(i, 26){
    last[i]=0;
  }
  int res=0;
  FOR(i, 1, D+1){
    last[tans[i]]=i;
    res+=s[i-1][tans[i]];
    REP(j, 26){
      res-=c[j]*(i-last[j]);
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  time_t start=clock();
  cin>>D;
  REP(i, 26){
    cin>>c[i];
  }
  REP(i, D){
    REP(j, 26){
      cin>>s[i][j];
    }
  }
  REP(i, D){
    ans[i]=xor32()%26;
    tans[i]=ans[i];
  }
  int score=val();
  while(true){
    time_t end=clock();
    if((double)(end-start)/CLOCKS_PER_SEC*1000>1950){
      break;
    }
    int d=xor32()%D, x=xor32()%26;
    tans[d]=x;
    int tmp=val();
    if(tmp>score){
      score=tmp;
      ans[d]=x;
    }
  }
  REP(i, D){
    cout<<ans[i]+1<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

#include <iostream>
 
int main(void)
{
    int64_t a;
    std::string s;
    std::cin >> a >> s;

    std::cout << (a < 3200 ? "red" : s) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a + b, min(b + c, c + a)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000000000000000
#define MOD 1000000007 

void func()
{
    ll n;
    cin>>n;
    ll t=ceil(n*1.0/1000);
    ll ans=1000*t-n;
    cout<<ans<<"\n";
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3752
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
//const long long mod = 1000000007;
const long long mod = 998244353;
using std::vector;
using std::pair;
using std::string;
using std::map;
int main() {
	int N, K, C;
	scanf("%d %d %d", &N, &K, &C);
	auto S = new char[N + 1];
	scanf("%s", S);
	vector<int> jobday;
	for (int i = 0; jobday.size() < K; i++) {
		if (S[i] == 'o') {
			jobday.push_back(i);
			i += C;
		}
	}
	int d = N - 1;
	vector<int>res;
	for (int i = K - 1; i >= 0; i--) {
		while (S[d] == 'x') d--;
		if (d == jobday[i])res.push_back(d);
		d -= C + 1;
	}
	std::sort(res.begin(), res.end());
	for (int i = 0; i < res.size(); i++) {
		printf("%d\n", res[i] + 1);
	}
	return 0;
}

Measured memory_bytes: 3316
#include<stdio.h>
int get(int a,int b){
  int r;
  r=a%b;
  if(r==0){
    return b;
  }else{
    return get(b,r);
  }
}
int gcd(int a,int b,int c){
  return get(get(a,b),c);
}
int main(void){
  int K,a,b,c,sum=0;
  scanf("%d",&K);
  for(a=1;a<=K;a++){
    for(b=1;b<=K;b++){
      for(c=1;c<=K;c++){
        sum+=gcd(a,b,c);
      }
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1712
n = int(input())
f = True
w = input()
used = set([w])
last = w[-1]
for i in range(n-1):
    w = input()
    if w in used or w[0]!=last:
        f = False
        break
    else:
        used.add(w)
        last = w[-1]
if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9132
#include <stdio.h>


int main(){
	int h[3]={0,0,0};
	int c,i;
	
	for(i=0;i<10;i++){
		scanf("%d",&c);
		if(c>h[0]){
			h[2]=h[1];
			h[1]=h[0];
			h[0]=c;
		}else if(c>h[1]){
			h[2]=h[1];
			h[1]=c;
		}else if(c>h[2]){
			h[2]=c;
		}
	}
	
	for(i=0;i<3;i++){
		printf("%d\n",h[i]);
	}
}

Measured memory_bytes: 1028
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val as = List.fill(n)(sc.nextInt())
  val r = 0 to 3200 by 400
  val cs = as.map(a => r.lastIndexWhere(_ <= a))
  val colors = cs.filter(_ != 8).distinct.length
  val x = cs.count(_ == 8)
  val min = colors.max(1)
  val max = colors + x
  println(s"$min $max")
}

Measured memory_bytes: 55360
N,A,B,C,D=map(int,input().split())
m=(N//A)*B
n=((N//A)+1)*B
s=(N//C)*D
t=((N//C)+1)*D
if N%A == 0 and N%C == 0:
    if m < s:
        print(m)
    else:
        print(s)
elif N%A == 0 and N%C >=1:
    if m < t:
        print(m)
    else:
        print(t)
elif N%A >= 1 and N%C == 0:
    if n < s:
        print(n)
    else:
        print(s)
elif N%A >= 1 and N%C >= 1:
    if n < t:
        print(n)
    else:
        print(t)
        


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()

int main() 
{
	 // #ifndef ONLINE_JUDGE
  //       freopen("input.txt", "r", stdin);
  //       freopen("output.txt", "w", stdout);
  //   #endif
  //   fastio();
	string s;
	cin>>s;
	ll num = stoi(s);
	if(num/100>0 && num/100<13)
	{
		if(num%100>0 && num%100<13)
			cout<<"AMBIGUOUS";
		else
			cout<<"MMYY";
	}
	else if(num%100>0 && num%100<13)
	{
		if(num/100>0 && num/100<13)
			cout<<"AMBIGUOUS";
		else
			cout<<"YYMM";
	}
	else
		cout<<"NA";

}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

ll a, b;

map<ll, ll> prime_factor(ll n)
{
    map<ll, ll> ret;
    for(ll i = 2; i*i <= n; i++){
        while(n % i == 0){
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

void solve()
{
    map<ll, ll> pa, pb;
    pa = prime_factor(a);
    pb = prime_factor(b);
    ll ans = 0;
    ll n = max(a, b);
    for(ll i = 2; i*i <= n; i++){
        if(pa.find(i) != pa.end() && pb.find(i) != pb.end()){
            ans++;
        }
        if(i != n/i){
            if(pa.find(n/i) != pa.end() && pb.find(n/i) != pb.end()){
                ans++;
            }
        }
    }
    if(pa.find(n) != pa.end() && pb.find(n) != pb.end()){
        ans++;
    }
    cout << ans+1 << endl;
}

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

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

typedef long long ll;

struct Pos { int x, y; };

const int v = 100000;
bool used[v*2];
vector<int> to[v*2];

void dfs(int s, set<int> &sx, set<int> &sy) {
  ll ret = 0;
  used[s] = true;
  if (s >= v) sy.insert(s);
  else sx.insert(s);
  for (int t: to[s]) {
    if (used[t]) continue;
    dfs(t, sx, sy);
  }
  return;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) { 
    int x, y;
    cin >> x >> y;
    --x; --y;
    y += v;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  ll ans = 0;
  for (int i = 0; i < v*2; ++i) {
    if (used[i]) continue;
    set<int> sx, sy;
    dfs(i, sx, sy);
    ans += (ll)sx.size()*(ll)sy.size();
  }
  ans -= n;
  cout << ans << endl;
}


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

int main() {
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        long N = nl();
        long X = nl();
        long M = nl();
        Doubling doubling = new Doubling(M);
        long ans = doubling.run(N, X, M);
		System.out.println(ans);
    }
    class Doubling{
        long[][] pre;
        public Doubling(long MaxPeriod){
            this.pre = new long[(int)MaxPeriod][2];
            for (int i = 0; i < MaxPeriod; i++) {
                for (int j = 0; j < 2; j++) {
                    pre[i][j] = -1;
                }
            }
        }
        public long run(long N, long X, long M){
            long ans = 0;
            for (long i = 0; i < N; i++) {
                ans += X;
                if(pre[(int)X][0] != -1){
                    long period = i-pre[(int)X][0];
                    long sum = ans - pre[(int)X][1];
                    long res = N-1-i;
                    ans+=res/period*sum;
                    i+=res/period*period;
                }
                pre[(int)X][0] = i;
                pre[(int)X][1] = ans;
                X = X*X%M;
            }
            return ans;
        }
    }
    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 36668
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * 不安なら ll を使う.
 * 小数は double を忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
 * 比較するときは型まで注意
 * 区間の計算は累積和
*/

/* ===== コーナーケースに気をつけろ ===== */

int main()
{
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    REP(i, N)
    {
        cin >> A.at(i);
    }
    ll sum = 0;
    ll m = -1;
    REP(i, N)
    {
        if (!i)
            continue;
        if (i == N - 1)
        {
            if (A.at(0) == 0)
            {
                sum += K - A.at(i);
                m = max(m, K - A.at(i));
            }
            else
            {
                sum += K - A.at(i) + A.at(0);
                m = max(m, K - A.at(i) + A.at(0));
            }
        }
        sum += A.at(i) - A.at(i - 1);
        m = max(m, A.at(i) - A.at(i - 1));
    }
    cout << sum - m << endl;
    return 0;
}

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

int main(){
    ll x;
    cin>>x;
    ll a,b;
    a=x/500;
    x-=a*500;
    b=x/5;
    cout<<1000*a+5*b<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse,sse2")
#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;

template<class T>
using ordered_set = tree <T, null_type ,  less<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree <T, null_type ,  less_equal<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;

#define all(x) x.begin(), x.end()
#define all_r(x) x.rbegin(), x.rend()
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, n) for(int i = n; i >= 0; --i)
#define f first
#define s second
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	map<int, int> F;
	const int MAXN = 1e6 + 1;
	bitset<MAXN> S;
	int cnt = 0;
	FOR(i, n) {
		int a;
		cin >> a;
		++F[a];
	}
	for(auto& p : F) {
		int a = p.f, b = p.s;
		for(int k = 2 * a; k < MAXN; k += a) S[k] = 1;
		if(b == 1 && !S[a]) ++cnt;
	}
	cout << cnt << '\n';
 	return 0;
}

Measured memory_bytes: 13092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int H,W;cin>>H>>W;
  vector<string> s(H+2,"");
  rep(i,W+2){
    s[0]+='.';
    s[H+1]+='.';
  }
  for(int i=1;i<=H;++i){
    string str;cin>>str;
    s[i].append(".");
    s[i].append(str);
    s[i].append(".");
  }
  bool flag=true;
  for(int i=1;i<H+1;++i){
    for(int j=1;j<W+1;++j){
      if(s[i][j]=='#' && ((s[i-1][j]=='.' && s[i+1][j]=='.') && ( s[i][j+1]=='.' && s[i][j-1]=='.'))) flag=false;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  qsort(a, n, sizeof(long), cmpnum);
  int pick = 0;
  long answer = 1;
  for (long i = 0; i < n; i++) {
    if (a[i+1] == a[i]) {
      answer *= a[i];
      pick += 2;
      i++;
    }
    if (pick == 4) {
      break;
    }
  }
  if (pick == 4) {
    printf("%ld\n", answer);
  } else {
    printf("0\n");
  }

  return 0;
}

Measured memory_bytes: 1788
#include <stdio.h>
int main(void){
	char a[5];
	scanf("%s",a);
	if(a[0]==a[1]){
		if((a[2]==a[3])&&(a[1]!=a[2])){
			printf("Yes");
		}else{
			printf("No");
		}
	}else if(a[0]==a[2]){
		if((a[1]==a[3])&&(a[0]!=a[1])){
			printf("Yes");
		}else{
			printf("No");
		}
	}else if(a[0]==a[3]){
		if((a[1]==a[2])&&(a[0]!=a[1])){
			printf("Yes");
		}else{
			printf("No");
		}
	}else{
		printf("No");
	}
	return 0;
}

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

typedef struct {
	double x;
	double y;
} Point;

void kock( int, Point, Point );

int main( void ){
	int n;
	Point p1, p2;
	
	p1.x = 0.0;//端点x座標(開始点)
	p1.y = 0.0;//端点y座標(開始点)
	p2.x = 100.0;//端点x座標(終了点)
	p2.y = 0.0;//端点y座標(終了点)
	
	scanf("%d", &n );
	printf("%g %g\n", p1.x, p1.y);
	
	kock( n, p1, p2 );
	
	printf("%g %g\n", p2.x, p2.y );
	
	return 0;
}

void kock( int n, Point p1, Point p2 ){
	if( n == 0 ){
		return;
	}
	
	Point s, t, u;
	
	s.x = p1.x + (p2.x-p1.x)/3.0;
	s.y = p1.y + (p2.y-p1.y)/3.0;
	
	t.x = p1.x + 2.0*(p2.x-p1.x)/3.0;
	t.y = p1.y + 2.0*(p2.y-p1.y)/3.0;
	
	u.x = (t.x-s.x) * cos(M_PI/3.0) - (t.y-s.y) * sin(M_PI/3.0) + s.x;
	u.y = (t.x-s.x) * sin(M_PI/3.0) + (t.y-s.y) * cos(M_PI/3.0) + s.y;
	
	kock( n-1, p1, s );
	printf("%g %g\n", s.x, s.y );
	
	kock( n-1, s, u );
	printf("%g %g\n", u.x, u.y );
	
	kock( n-1, u, t );
	printf("%g %g\n", t.x, t.y );
	
	kock( n-1, t, p2 );
}


Measured memory_bytes: 2056
#140
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

res = 0
for i in range(0,n):
    res += b[a[i]-1]
    if i > 0 and a[i]-1 == a[i-1]:
        res += c[a[i-1]-1]
        
print(res)

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

int main() {
  
  long long X,N;
  
  cin >> X >> N;
  
  vector<long long> p(N);
  vector<bool> li(1000,true);
  
  
  for (int i=0; i<N; i++) {
    cin >> p[i];
    li[p[i] + 500] = false;
  }
  
  for (int i=0; i<300; i++) {
    if (li[X-i+500]) {
      cout << X-i << endl;
      return 0;
    }
    if (li[X+i+500]) {
      cout << X+i << endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 3636
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using i_i = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const ll mod = 1000000007LL;


int main() {
	int x;
	cin >> x;
	cout << (x == 0 ? 1 : 0) << endl;

	return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    if(i%3==0 || i%5==0)
    {
        
    }
    else
    ans+=i;
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 3512
//#include<bits/stdc++.h>
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<pair<int, int> > v(n);
	for (int j = 0; j < n; j++)
		cin >> v[j].first >> v[j].second;

	sort(v.begin(), v.end());

	for (int j = 0; j < n; j++)
		cout << v[j].first << " " << v[j].second << endl;
	return 0;
}


Measured memory_bytes: 3632
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [h,w] <- map (read::String->Int) . words <$> getLine
  as <- lines <$> getContents
  (putStrLn .unlines .transpose .comp .transpose .comp) as

comp ls = map snd $ filter ((==False).fst) $zip (map (all (=='.')) ls) ls

Measured memory_bytes: 5732
n, m = map(int, input().split())
hs = list(map(int, input().split()))

edge = [[] for _ in range(n)]

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

cnt = 0

for node in range(n):
    good = True
    for neighbor in edge[node]:
        if hs[node] <= hs[neighbor]:
            good = False
    if good:
        cnt += 1

print(cnt)

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

int main() {
  long long l,r;
  cin >> l >> r;
  r = min(r,l+2019);
  int ans = 2018;
  for(long long i = l;i <= r;i++){
    for(long long j = i+1;j <= r;j++){
      int x = (i*j)%2019;
      ans = min(ans,x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()

def is_yymm(s):
    if 1<=int(s)<=12:
        return "both"
    else:
        return "YY"

left = is_yymm(S[:2])
right = is_yymm(S[2:])

ans = left + right

if ans=="YYboth":
    print("YYMM")
elif ans=="bothYY":
    print("MMYY")
elif ans=="bothboth":
    print("AMBIGUOUS")
else:
    print("NA")

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  inputInt(N);
  //vector<string> s(N);
  map<string, ll> mp;
  for(int i=0; i<N; i++){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    auto itr = mp.find(s);
    if(itr != mp.end()){
       itr->second += 1;
    }else{
       mp[s] = 1;
    }
  }
  
  //main
  ll ans = 0;
  for(auto m:mp){
     ans += (m.second)*(m.second-1)/2;
  }

  // output
  output(ans);
    
  return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;
ll n;
vector<ll> a;
vector<vector<ll> > adj(300009);
vector<ll> ans;
vector<ll> dp;

pair<ll,pair<ll,ll> >  fun(ll x)
{
  auto it=lower_bound(dp.begin(),dp.end(),x);
  ll f;
  if(it==dp.end()) dp.pb(x),f=-1;
  else f=*it,*it=x;

  ll z=dp.size();
  return {f,{z,it-dp.begin()}};
}

void dfs(ll node,ll par)
{
  pair<ll,pair<ll,ll> >p=fun(a[node]);
  ans[node]=p.ss.ff;

  for(auto j:adj[node])
  if(j!=par)dfs(j,node);

  
  if(p.ff==-1)dp.pop_back();
  else
   dp[p.ss.ss]=p.ff;

}

int main()
{ 

fast;
cin>>n;
a.assign(n,0);
for(ll i=0;i<n;i++)cin>>a[i];
  ans.assign(n,1);


for(ll i=0;i<n-1;i++)
{
  ll x,y;
  cin>>x>>y;
  x--,y--;
  adj[x].pb(y);
  adj[y].pb(x);
}
dfs(0,-1);

for(ll i=0;i<n;i++)
cout<<ans[i]<<'\n';


}

Measured memory_bytes: 34012
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007

typedef long long ll;

using namespace std;


int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
int gcd(int x, int y)
{
    if(x%y==0)return y;
    else if(y%x==0)return x;
    else return gcd(x%y,y%x);
}
ll gcd(ll x, ll y)
{
    if(x%y==0)return y;
    else if(y%x==0)return x;
    else return gcd(x%y,y%x);
}
//AGC018B
int main()
{
    int n;
    cin >> n;
    if(n!=0)
    {
        stack<int> S;
        while(n!=0)
        {
            S.push(abs(n%2));
            n=-1*((n-abs(n%2))/2);
        }
        while(!S.empty())
        {
            cout << S.top();
            S.pop();
        }
        cout <<endl;
    }
    else W(0)
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
    string s1, s2, s3;

    cin >> s1 >> s2 >> s3;

    char ch1 = toupper(s1[0]);
    char ch2 = toupper(s2[0]);
    char ch3 = toupper(s3[0]);

    cout << ch1 << ch2 << ch3 << endl;

}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    cout << setprecision(20);
    ll n;
    cin >> n;
    ll x = (n*100+107)/108;
    if((x*108)/100==n) cout << x << endl;
    else cout << ":(" << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

a.insert(0, 0)
a.append(0)
tmp = 0
for i in range(n + 1):
    tmp += abs(a[i + 1] - a[i])
#print(tmp)

for i in range(1, n + 1):
    #print(abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]) , abs(a[i + 1] - a[i - 1]))
    ans = tmp - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1])
    print(ans)


Measured memory_bytes: 14176
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	K := nextInt()
	N := nextInt()
	A := nextInts(N)
	maxLength := 0
	for i := 0; i < N-1; i++ {
		if A[i+1]-A[i] > maxLength {
			maxLength = A[i+1] - A[i]
		}
	}
	if (K-A[N-1])+A[0] > maxLength {
		maxLength = (K - A[N-1]) + A[0]
	}
	fmt.Println(K - maxLength)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

int n;

signed main() {
	cin >> n;
	if (n >= 1000) cout << "ABD" << endl;
	else cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>

using namespace std;

int main(){

	int ans=0;
	int n,m;
	cin>>n>>m;
	if(n==m)cout<<"Yes";
	else cout<<"No";


	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int i, n, m;
char c[100];

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

  if(strlen(c) != n + m + 1) return 0 * puts("No");

  for(i = 0; i < n; ++i)
    if(c[i] < '0' || c[i] > '9') return 0 * puts("No");

  if(c[n] != '-') return 0 * puts("No");

  for(i = 0; i < m; ++i)
    if(c[i + n + 1] < '0' || c[i + n + 1] > '9') return 0 * puts("No");

  puts("Yes");

  return 0;
}

Measured memory_bytes: 256
def convert(i,n):
    arr = []
    for k in range(n):
        arr = [i%2]+arr
        i = int(i/2)
    return arr

def copy(a,n,m):
    arr = [[0 for i in range(m)] for j in range(n)]
    for i in range(n):
       for j in range(m):
           arr[i][j] = a[i][j]
    return arr

def main():
    h,w,k = map(int,input().split())
    c = [['' for j in range(w)] for i in range(h)]
    for i in range(h):
        s = input()
        for j in range(w):
            c[i][j] = s[j]
    H = 2**h
    W = 2**w

    ans = 0
    for row in range(H):
        for col in range(W):
            t = copy(c,h,w)
            #print(t)
            rowb = convert(row,h)
            colb = convert(col,w)
            #print(rowb)
            #print(colb)
            for i in range(h):
                if rowb[i]==1:
                    for j in range(w):
                        t[i][j] = '_'
            for j in range(w):
                if colb[j]==1:
                    for i in range(h):
                        t[i][j] = '_'
            #print(t)
            black = 0
            for i in range(h):
                black += t[i].count('#')

            if black==k:
                ans += 1

    print(ans)
    return
                    
    
    

if __name__=='__main__':
    main()


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

using namespace std;

void recur(int n, vector<int> &v){
	int size = static_cast<int>(v.size());
	for(int i = (size == 0) ? n : min(n, v[size - 1]); i > 0; i--){
		v.push_back(i);
		if(i == n){
			for(int j = 0; j <= size; j++){
				cout << v[j] << (j != size ? ' ' : '\n');
			}
		}else{
			recur(n - i, v);
		}
		v.pop_back();
	}
}

int main(){
	while(true){
		int n = 0;
		cin >> n;
		if(n == 0){ break; }
		vector<int> v;
		recur(n, v);
	}
	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <climits>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef pair<int, int> pii;

bool calc(string b)
{
	if (b.size() == 0)return true;
	for (char i = '1'; i <= '9'; i++)
	{
		if (count(all(b), i) >= 3)
		{
			string c = b;
			c.erase(c.find(i), 3);
			if (calc(c))return true;
		}
	}
	for (char i = '1'; i <= '9' - 2; i++)
	{
		if (count(all(b), i) && count(all(b), i + 1) && count(all(b), i + 2))
		{
			string c = b;
			c.erase(c.find(i),1);
			c.erase(c.find(i+1),1);
			c.erase(c.find(i+2),1);
			if (calc(c))return true;;
		}
		
	}
	return false;
}

bool check(string a)
{
	for (int i = 1; i <= 9; i++)
	{
		if (count(all(a), '0' + i) > 4)return false;
	}

	for (int i = 1; i <= 9; i++)
	{
		if (count(all(a), '0' + i) >= 2)
		{
			string b = a;
			b.erase(b.find('0' + i, 0),2);
			if (calc(b))return true;
		}
	}
	return false;
}

int main()
{
	string a;
	while (cin >> a)
	{
		vector<int> ans;
		for (int i = 1; i <= 9; i++)
		{
			string b = a;
			b += '0' + i;
			sort(all(b));
			if (check(b))ans.push_back(i);
		}
		if (ans.empty())
		{
			cout << 0 << endl;
		}
		else
		{
			for (int i = 0; i < ans.size(); i++)
			{
				cout << (i == 0 ? "" : " ") << ans[i];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1216
/*input
100000 5




*/
/*
<!--> 		^_^  ^_^  ^_^
		   _____________
		  /				/
AUTHOR  :/ thesyncoder /
		/_____________/
			T_T   T_T
YOU yourself can be less noob than the one 
you are right now 
just with a little coffee.
<!-->
*/
#include <bits/stdc++.h>
using namespace std;

// ALL DEFFINES HERE
#define ll long long int
#define ii pair<int, int>
#define mp make_pair
#define N 100005
#define rep(i, n) for(int i=0; i < n; i++)
#define Rep(i, k, n) for(int i=k; i < n; i++)
#define pb push_back
#define vi vector<int>
#define vii vector< vector<int> >
#define vl vector<ll>
#define F first
#define S second

// ALL declarations here const ints etc
const  ll mod =1000000000+7; 

// IMPORTANT FUNCTION DECLARATIONS , 
//SORRY FOR THE BAD PRESENTATION
ll gcd(ll a, ll b)
{
	if ( b==0)
		return a;
	return gcd(b, a%b);
}
ll absl(ll a )
{
	return  a>= 0 ?a:-a;
}
ll maxl(ll a, ll b)
{
	return a >= b? a:b;
}
ll exp(ll a, ll n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return a* exp(a*a, n/2);
	else
		return exp(a*a, n/2);
}
// --->>> main starts here
int primes[100000];
void seive()
{
	primes[0]=1;primes[1]=1;
	for ( int i=2; i*i <= 100000; i++)
	{
		for ( int j=i*2; j <= 100000; j+=i)
		if ( !primes[j])
		{
			primes[j] =1; 
		}
	}
}
int deflog(int n)
{
	if ( log(n) / log(2) - (int) ( log(n)/log(2)) < 1e-6)
		return (int) ( log(n)/log(2));
	else
		return (int) ( log(n)/log(2)) +1;
}
int main()
{
	int n, k;
	cin >> n >> k;
	long double p =0.0;
	ll base =2;
	for (int i=n; i >=1; i--)
	{
		if ( k <= i)
			p+=1.0;
		else
		{
			int times;
			if ( k%i==0)
				 times =deflog(k/i);
			else
		 times = deflog(k/i+1);
		ll po;
		po = exp(1LL*base , 1LL * times);
		// cout << times << "\n";
		p+= 1.0/ (1.0*(double)po);
	}

	}
	p = p* (1.0/(1.0*(double)n));
	cout<< setprecision(9) << p;

}

		








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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"


int main()
{
	int a,b;
	
	cin >> a >> b;
	
	cout << max(a+b, max(a-b,a*b)) << endl;
	
	return 0;
}


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

int N, K, h_N, org;

int main () {
	cin >> N >> K ;
	for (int i=1; i<=N; i++) {
		cin >> h_N;
		if (h_N>=K) {
			org++;
		}
	} cout << org << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int i[1000001];

int main(){

	int k,j,n;

	for(k=1;k<=1000000;k=k+1){
		i[k]=k;
	}

	i[1]=0;

	for(k=2;k<=1000000;k++){
		for(j=2;j<=1000000/k;j++){
			i[k*j]=0;
		}
	}


	while(~scanf("%d",&n)){
		if(n==1){
			printf("0\n");
			continue;
		}

		j=0;
		for(k=1;k<=n;k++){
			if(i[k]!=0)
				j=j+1;
		}
		printf("%d\n",j);
	}
	return 0;
}

Measured memory_bytes: 4316
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include<iostream>
using namespace std;
int main()
{
	long long a, b, c, d, N, teban, i, j, k;
	char A[102];
	char B[102];
	char C[102];

	cin >> A;
	cin >> B;
	cin >> C;

	cout << A[0] << B[1] << C[2];


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b;
	scanf("%d %d %d",&k,&a,&b);
	for(int i=a;i<=b;++i){
		if(i%k==0){
			printf("OK\n");
			break;
		}
		if(i==b){
			printf("NG\n");
		}
	}
}

Measured memory_bytes: 3764
#include <stdio.h>

int main(){

  int n,a,ans=0,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d",&a);

    for(j=2;j*j<=a;j++) if(a%j==0) goto loop;
    ans++;

  loop:;

  }

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

  return 0;

}



Measured memory_bytes: 2064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define MOD 1000000007
#define PB push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=3E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=998244353;
LL qpow(LL a,LL b){
    LL ret=1;
    while(b){
        if(b&1) ret*=a;
        a*=a;
        b>>=1;
    }
    return ret;
}
void solve(){
    LL x,y;cin>>x>>y;
    if(x<y) swap(x,y);
    LL t=x-y;
    if(t==1||t==0) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}
int main(){
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    IOS;
    int T;T=1;
    while(T--){
        solve();
    }
    return 0;
}


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

#define fastIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;

int N, M;
vector<vector<int>> adj_mat;
vector<int> max_path_len;

int dfs(int i)
{
    if (max_path_len[i] == INT_MIN)
    {
        max_path_len[i] = 0;
        for (auto j : adj_mat[i])
            max_path_len[i] = max(max_path_len[i], 1 + dfs(j));
    }
    return max_path_len[i];
}

int main()
{
    fastIO;
    cin >> N >> M;
    adj_mat.resize(N + 1);
    max_path_len.resize(N + 1, INT_MIN);
    int x, y;
    while (M--)
    {
        cin >> x >> y;
        adj_mat[x].push_back(y);
    }
    int ans = 0;
    for (int i = 1; i <= N; i++)
        ans = max(ans, dfs(i));
    cout << ans;
}

Measured memory_bytes: 10964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int ACC =0;
  int WAC =0;
  int TLEC =0;
  int REC =0;
  cin >> N;
  vector<string> S(N);
  
  for(int i =0; i < N; i++) {
    cin >> S.at(i);
    if(S.at(i) == "AC") ACC++;
    if(S.at(i) == "WA") WAC++;
    if(S.at(i) ==  "TLE") TLEC++;
    if(S.at(i) == "RE") REC++;
  }
  cout << "AC" << " " << "x" << " " << ACC  << endl;
  cout <<  "WA" << " " << "x" << " " << WAC  << endl;
  cout <<  "TLE" << " " << "x" << " " << TLEC  << endl;
  cout <<  "RE" << " " << "x" << " " << REC  << endl;
}

Measured memory_bytes: 6412
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n, c;
    cin >> n >> c;
    vector<vector<int>> d(c + 1, vector<int>(c + 1));

    for(int i = 1; i <= c; i++){
        for(int j = 1; j <= c; j++){
            cin >> d[i][j];
        }
    }

    vector<vector<int>> grid(n + 1, vector<int>(n + 1));

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> grid[i][j];
        }
    }

    vector<vector<int>> cs(3, vector<int>(c + 1, 0));


    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cs[(i + j) % 3][grid[i][j]]++;
        }
    }
    ll ans = INF;
    for(int i = 1; i <= c; i++){
        for(int j = 1; j <= c; j++){
            for(int k = 1; k <= c; k++){
                if(i == k || j == k || i == j) continue;
                ll tmpans = 0;
                for(int l = 1; l < cs[0].size(); l++){
                    tmpans += d[l][i] * cs[0][l];
                }
                for(int l = 1; l < cs[1].size(); l++){
                    tmpans += d[l][j] * cs[1][l];
                }
                for(int l = 1; l < cs[2].size(); l++){
                    tmpans += d[l][k] * cs[2][l];
                }
                
                ans = min(ans, tmpans);

            }
        }
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;

const ll mod = 1000000007;
const ll INF = 1000000000000;
ll N, H[100010];

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return pow_mod(x, y - 1) * x % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	reverse(H, H + N);
	bool jud = true;
	for (int i = 1; i < N; i++)
	{
		if (H[i] <= H[i - 1]) continue;
		H[i]--;
		if (H[i] > H[i - 1]) jud = false;
	}

	if (jud)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	int www;
	cin >> www;
}

Measured memory_bytes: 1024
MOD = 10**9 + 7

n, a, b = map(int, input().split())

def modpow(a, n):
  res = 1
  while (n > 0):
    if (n & 1):
      res = (res * a) % MOD
    a = (a**2) % MOD
    n >>= 1
  return res

def make_nCk_tables(n):
  M = min(n, 2*10**5)
  nCk = [0]*(M+1)
  nCk[0], nCk[1] = 1, n
  inv = [0]*(M+1)
  inv[0], inv[1] = 0, 1
  for k in range(2, M+1):
    inv[k] = MOD + (-inv[MOD % k] * (MOD//k)) % MOD
    nCk[k] = ((nCk[k-1] * (n-k+1)) % MOD) * inv[k] % MOD
  return nCk

nCk = make_nCk_tables(n)
ans = modpow(2, n)-1
ans = (ans - nCk[a]) % MOD
ans = (ans - nCk[b]) % MOD
print(ans)


Measured memory_bytes: 18868
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = (int)n-1; i >= 0; i--)
#define ll long long int
#define pb push_back
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  string ans = "";
  while(0 < N){
    int a = N % 26;
    if(a==0) {
      a=26;
      N--;
    }
    a--;
    ans += 'a' + a;
    if(N == 26) break;
    N /= 26;
  }
  r_rep(i, ans.size()){
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 3128
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String c[][] = new String[H][W];
		for(int i = 0; i < H; i++) {
			String s = sc.next();
			for(int j = 0; j < W; j++) {
				c[i][j] = s.substring(j, j + 1);
			}
		}
		int ans = 0;
		for (int i = 0; i < (Math.pow(2, H)); i++) {
			for (int j = 0; j < (Math.pow(2, W)); j++) {
				String temp[][] = new String[H][W];
				for(int k = 0; k < H; k++) {
					temp[k] = c[k].clone();
				}
				for (int a = 0; a < H; a++) {
					if ((1&i>>a) == 1) {
						for(int k = 0; k < W; k++) {
							temp[a][k] = "$";
						}
					}
				}
				for (int b = 0; b < W; b++) {
					if ((1&j>>b) == 1) {
						for(int k = 0; k < H; k++) {
							temp[k][b] = "$";
						}
					}
				}
				int cnt = 0;
				for(int y = 0; y < H; y++) {
					for(int x = 0; x < W; x++) {
						if(temp[y][x].equals("#")) {
							cnt++;
						}
					}
				}
				if(cnt == K) ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 39920
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    sl = [input() for _ in range(n)]

    counter = [[0] * 26 for _ in range(n)]

    for i in range(n):
        for c in sl[i]:
            counter[i][ord(c) - ord('a')] += 1

    ans = ''
    for i, a in enumerate(zip(*counter)):
        ans += chr(ord('a') + i) * min(a)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
struct Edge
{
	int to;
	int nxt;
}e[1000005];
int n,edgenum,head[1000005],a[1005][1005],d[1000005];
queue<int>q;
vector<int>s;
bool flag[1005];
void add(int u,int v)
{
	e[++edgenum].to=v;
	e[edgenum].nxt=head[u];
	head[u]=edgenum;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<n;j++)scanf("%d",&a[i][j]);
		for(int j=1;j<n-1;j++)
		{
			int x=i,y=a[i][j];
			if(x>y)swap(x,y);
			int v1=(x-1)*n+y;
			x=i,y=a[i][j+1];
			if(x>y)swap(x,y);
			int v2=(x-1)*n+y;
			add(v1,v2);
			d[v2]++;
		}
	}
	for(int i=1;i<=n*(n-1);i++)
	{
		int x=(i-1)/n+1;
		int y=(i-1)%n+1;
		if(x>=y)continue;
		if(d[i]==0)q.push(i);
	}
	int ans=0;
	int num=0;
	while(!q.empty())
	{
		int node=q.front();
		q.pop();
		num++;
		int x=(node-1)/n+1;
		int y=(node-1)%n+1;
		if(flag[x]||flag[y])
		{
			int x=(int)s.size();
			for(int i=0;i<x;i++)
			  flag[s[i]]=0;
			s.clear();
			ans++;
		}
		flag[x]=flag[y]=1;
		s.push_back(x);
		s.push_back(y);
		for(int hd=head[node];hd;hd=e[hd].nxt)
		{
			int to=e[hd].to;
			d[to]--;
			if(d[to]==0)q.push(to);
		}
	}
	if(num==n*(n-1)/2)printf("%d\n",ans+1);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 19840
#n = int(input())
a, b, c = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

if a == b :
    print(c)
elif b == c :
    print(a)
else:
    print(b)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n, m;
	cin >> n >> m;
	priority_queue<pair<ll, ll>> pq;
	
	ll x, y;
	REP(i, 0, n){
		cin >> x >> y;
		pq.push(MK(-x, y));
	}
	ll price = 0;
	while(m > 0){
		pair<ll, ll> tmp = pq.top();
		pq.pop();
		if(tmp.S > m) price += -tmp.F*m;
		else price += -tmp.F*tmp.S;
		m-= tmp.S;
	}
	cout << price;

}


Measured memory_bytes: 2420