akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        String line;
        int n = 0;
        int a = 0;
        int b = 0;
        ArrayList<Integer> p = new ArrayList<Integer>();
        
        for(int i = 0; cin.hasNext(); i++){
	        line = cin.nextLine();
	        
	        if(i == 0) {
	            n = Integer.parseInt(line);
	            
	        } else if(i == 1) {
	            String[] ab = line.split(" ", 0);
	            
	            for(int j = 0; j < 2; j++) {
	                if(j == 0) {
	                    a = Integer.parseInt(ab[j]);
	                    
	                } else if(j == 1) {
	                    b = Integer.parseInt(ab[j]);
	                    
	                } else {
	                    
	                }
	                
	            }
	            
	        } else if(i == 2) {
	            String[] ps = line.split(" ", 0);
	            
	            for(int j = 0; j < ps.length; j++) {
	                p.add(Integer.parseInt(ps[j]));
	                
	            }
	            
	        } else {
	            
	        }
	        
        }
        
        int s = 0;
        int m = 0;
        int l = 0;
        
        for(int i = 0; i < p.size(); i++) {
            if(p.get(i) <= a) {
                s++;
                
            } else if(p.get(i) > a && p.get(i) <= b) {
                m++;
                
            } else if(p.get(i) > b) {
                l++;
                
            }
            
        }
        
        int min = s;
        
        if(min > m) {
            min = m;
        }
        
        if(min > l) {
            min = l;
            
        }
        
        System.out.println(min);
        
    }
    
}


Measured memory_bytes: 23892
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = list(map(int, sys.stdin.readline().split()))

if K % 2 == 1:
    print(0)
    exit()
if N == 1:
    if K == 0:
        print(1)
    else:
        print(0)
    exit()
if K == 0:
    print(1)
    exit()

# 解説AC
# dp[i][j][k]: i まで決まってて、保留の数が j、確定した奇妙さが k
dp = [[[0] * (K + 1) for _ in range(N)] for _ in range(N)]
dp[0][0][0] = 1
dp[0][1][2] = 1
for i, j, k in itertools.product(range(1, N), range(N - 1), range(K + 1)):
    if k - j * 2 < 0:
        continue
    # i == pi
    # 保留の数はそのまま
    # 奇妙さは保留の数だけ増える
    dp[i][j][k] += dp[i - 1][j][k - j * 2] * 1
    # i == p_j または j == p_i (j < i)
    # 保留の数はそのまま
    # 奇妙さは保留の数だけ増える
    # パターン数はうさぎの保留数j + かめの保留数j
    dp[i][j][k] += dp[i - 1][j][k - j * 2] * (j * 2)
    # i == p_j かつ j == p_j (j < i)
    # 保留数が1減る
    # パターン数はうさぎの保留数j * かめの保留数j
    dp[i][j][k] += dp[i - 1][j + 1][k - j * 2] * (j + 1) ** 2
    if j - 1 >= 0:
        # 両方保留
        # そのまま増やす
        dp[i][j][k] += dp[i - 1][j - 1][k - j * 2]

    dp[i][j][k] %= MOD
print(dp[-1][0][K])


Measured memory_bytes: 92892
using System;
using System.Collections.Generic;
using System.Linq;

namespace Welcome_to_AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }

            var maxValue = array.Max();
            var secondValue = array.OrderByDescending(_ => _).Skip(1).First();
            var hasMultipleMaxValue = maxValue == secondValue;

            foreach (var item in array)
            {
                if (item == maxValue)
                {
                    if (hasMultipleMaxValue)
                    {
                        Console.WriteLine(maxValue);
                    }
                    else
                    {
                        Console.WriteLine(secondValue);
                    }
                }
                else
                {
                    Console.WriteLine(maxValue);
                }
            }
        }
    }
}


Measured memory_bytes: 19924
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int m = sc.nextInt();
            int a[] = new int[m];
            for(int i=0;i<m;i++){
              a[i]=sc.nextInt();
            }
            
            for(int i=0;i<m;i++){
              n-=a[i];
            }
            if(n<0)n=-1;
            System.out.println(n);
            }

          }


Measured memory_bytes: 46184
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

 class FS {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}
public class Main {
    public static void main(String[] args) {
        FS fs = new FS();
        int n = fs.nextInt();
        int[][] graph = new int[n][n];
        for (int i = 0; i < n; i++) {
            int id = fs.nextInt();
            int degree = fs.nextInt();
            for (int j = 0; j < degree; j++) {
                graph[id - 1][fs.nextInt() - 1] = 1;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                sb.append(graph[i][j] + " ");
                if (j == n - 1) {
                    sb.deleteCharAt(sb.length() - 1);
                }
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}


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

int main() {
	int week;
	cin >> week;
	int debt = 100000;
	while (week--)
	{
		int rem = debt % 20000;
		debt = ((int)(debt * 1.05) / 1000) * 1000;
		if (rem > 0) { debt += 1000; }
	}
	cout << debt << endl;

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    if (K==2||K==5){cout << -1 << '\n'; return 0;}
    vector<int> app(K,0);
    ll now=0;
    for (int i=1;;++i){
        ((now*=10)+=7)%=K;
        if (now==0){
            cout << i << '\n';
            return 0;
        }
        if (app[now]){
            cout << -1 << '\n';
            return 0;
        }
        app[now]=1;
    }
}

Measured memory_bytes: 7156
#include<stdio.h>
int main()
{
	int a,b[9],i;
	while(1){
		scanf("%d",&a);
		if(a==0){
			break;
		}
		for(i=0;i<9;i++){
			scanf("%d",&b[i]);
			a-=b[i];
		}
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define nln printf("\n")
int  main()
{
    int n;
    scanf("%d", &n);
    int a[n];
    cin>>a[0]>>a[1];
    int m1,m2;

    if(a[0]>a[1])
    {
        m1=a[0];
        m2=a[1];
    }
    else
    {
        m1=a[1];
        m2=a[0];
    }

    for(int i=2;i<n;i++)
    {
        scanf("%d", &a[i]);

        if(a[i]>=m1)
        {
            m2=m1;
            m1=a[i];
        }

        else if(a[i]>m2 && a[i]<=m1)
        {
           m2=a[i];
        }
    }
//    cout<<m1<<" "<<m2;
//    nln;

    for(int i=0;i<n;i++)
    {
        if(a[i]==m1)
        {
            cout<<m2<<" ";
        }
        else
        {
            cout<<m1<<" ";
        }
    }


}


Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

#define int long long
#define double long double
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << '\n';
#define fi first
#define se second
#define pb push_back
//typedef long long ll;
typedef pair<int, int> pii;
 
void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

const int N = 2e5 + 10;
int p[N], pp[N];

void gcd(int a, int b, int &x, int &y) {
	if (a == 0) {
		x = 0; y = 1;
	} else {
		int x2, y2;
		gcd(b % a, a, x2, y2);
		x = y2 - (b / a) * x2;
		y = x2;
	}
}

signed main() {
	fast();
	int n;
	cin >> n;
	int m = 0;
	n *= 2;
	int ans = n;
	for (int i = 2; i * i <= n; i++) {
		if (n % i != 0) continue;
		p[m] = i; pp[m] = 1;
		while (n % i == 0) {
			n /= i;
			pp[m] *= i;
		}
		m++;
	}
	if (n > 1) {
		p[m] = pp[m] = n;
		m++;
	}
	int pw = (1 << m);
	for (int msk = 0; msk < pw; msk++) {
		int t = msk;
		int a = 1, b = 1;
		for (int j = 0; j < m; j++, t /= 2) {
			if (t & 1) a *= pp[j];
			else b *= pp[j];
		}
		int x, y;
		gcd(a, b, x, y);
		//debug(a * b << ' ' << x << ' ' << y)
		int k = y * b - 1;
		k %= a * b;
		while (k <= 0) k += a * b;
		if (k == 4742) {
			//cout << a << ' ' << b << '\n';
		}
		if (k < ans) ans = k;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

typedef long long int ll;
#define push_back pb
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;

int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int power(int a, int b){
	if(b < 0)return 0;
	int re = 1;
	while(b){
		if(b&1){
			re = mul(re, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return re;
}
int const N = 100000 + 5;
int fact[N], inverse[N];
void FAC(){
 	fact[0] = 1;
	for(int x = 1; x< N; x++){
		fact[x] = mul(fact[x-1], x);
	}
	inverse[N-1] = power(fact[N-1], mod -2);
	for(int x = N-2; x>= 0; x--){
		inverse[x] = mul(x + 1, inverse[x+1]);
	}

 }

int ncr(int a, int b){
	if(a < b)return 0;
	return mul(fact[a], mul(inverse[a-b], inverse[b]));
}

/******************************************************/
void solve(){
	long long n, m;
	cin >> n >> m;
	long long lc, hc;
	vector<ll> vec(n), ch(2, 0);
	for(auto &a : vec)cin >> a, ch[(a/2)%2]= 1;
	int o = ch[0] + ch[1];
	if(o == 2){
		cout << 0 << endl;
		return ;
	}
	hc = lc = vec[0];
	for(int x =1; x<n; x++){
		hc = __gcd(vec[x] , lc);
		lc = (lc*vec[x]) / hc;
		if(lc/2 > m ){
			cout << 0 << "\n";
			return ;
		}
	}
  for(auto a: vec){
    if((lc/a)%2==0){
    cout <<0;
      return;
    }
  }
	// cout << lc << endl;
	ll ans = 0;
	if(lc/2 <= m)ans = min(1, int(lc/2)), m -= lc/2;
	ans += m / lc;
	cout << ans << "\n";
}


/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;

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

	int N; cin >> N;

	vector<int> arr(N);
	for (int& i : arr) cin >> i;

	sort(arr.rbegin(), arr.rend());

	ll sum = 0;
	for (int i = 0; i < N / 2; i++) {
		sum += 2 * arr[i];
	}

	sum -= arr[0];
	if (N & 1) sum += arr[N / 2];

	cout << sum;

	return 0;
}

Measured memory_bytes: 3988
// https://atcoder.jp/contests/dp/tasks/dp_e
#include<iostream>
#include <cstdlib>
#include <algorithm>
#include <limits.h>

using namespace std;


struct object{
	int weight,value;
};

object arr[107];
long long dp[100007][107];

long long res(int value, int n)
{
	if(value<=0)
		return 0;
	if(n==0)
		return INT_MAX;
	if(dp[value][n])
		return dp[value][n];
	dp[value][n] = min(res(value - arr[n-1].value, n-1) + arr[n-1].weight , res(value,n-1));
	return dp[value][n];
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,w, sum = 0;
	cin >> n >> w;
	for(int i=0;i<n;i++)
	{
		cin >> arr[i].weight >> arr[i].value;
		sum+=arr[i].value;
	}
	for(int i=sum;i>=0;i--)
	{
		if(res(i,n) <= w)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 86072
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<pair<ll, ll>> v;
  REP(i, N) {
    ll a, b; cin >> a >> b;
    v.PB(MP(a, b));
  }
  sort(ALL(v));

  ll cnt = 0;
  REP(i, N) {
    if (cnt + v[i].SE >= K) {
      cout << v[i].FI << endl;
      return 0;
    }
    cnt += v[i].SE;
  }

  return 0;
}

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

using namespace std;

using ll = long long;

int n, w;
vector<ll> weight, value;
vector<vector<ll>> dp;



ll solve(int i, int cap){
  if(i == n) return 0;
  if(dp[i][cap] != -1) return dp[i][cap];
  ll v = -1;
  if(cap >= weight[i]){
    v = max(solve(i+1, cap), value[i] + solve(i+1, cap-weight[i]));
  }else{
    v = solve(i+1, cap);
  }
  return dp[i][cap] = v;
}


int main() {
  int tmp, tmp1;
  cin>>n>>w;
  for(int i = 0; i < n; i++){
    cin>>tmp>>tmp1;
    weight.push_back(tmp);
    value.push_back(tmp1);
  }
  dp.assign(n, vector<ll>(w+1, -1));
  ll res = solve(0, w);
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 79488
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define hell        1000000007
#define N	    400001
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define ll          long long
#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)


#define track(x)                cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ll dp[N];
void solve(){
	int n, k;
	cin>>n>>k;
	rep(i,0,n) dp[i] = INT_MAX;
	dp[0] = 0;
	int a[n];
	rep(i,0,n) {
		cin>>a[i];
		for(int j = 1; j <= k; j++) {
			if(i - j < 0) break;
			dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
		}
	}
	cout<<dp[n-1]<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 1408
from collections import defaultdict
n = int(input())
dic = defaultdict(lambda : [])
for i in range(n):
    s, p = input().split()
    p = int(p)
    dic[s].append([p, i + 1])
dic = sorted(dic.items())
for t in dic:
    t = list(t[1:])
    t = t[0]
    t.sort(reverse = 1)
    for x in t:
        print(x[1])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

bool isprime[200010];
//エラトステネス
void eratos(int m){
    for (int i = 0; i <= m; ++i) isprime[i] = true;
    isprime[0] = isprime[1] = false;
    //iを残してiの倍数を消していく
    for (int i = 2; i <= m; ++i){
        if(isprime[i]){
            for (int j = 2 * i; j <= m; j += i){
                isprime[j] = false;
            }
        }
    }
}

int Q;
int l[100010], r[100010];

int main(void) {
	cin >> Q;
	rep(i, Q) cin >> l[i] >> r[i];

	eratos(100000);
	vector<int> n(100010);
	reps(i, 3, 100001) {
		if (i % 2 == 0) continue;
		if (isprime[i] && isprime[(i + 1) / 2]) n[i] = 1;
	}
	rep(i, 100001) n[i + 1] += n[i];

	rep(i, Q) {
		cout << n[r[i]] - n[l[i] - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <set>
using namespace std;
int a;
int main(){
  cin >> a;
  set<int> s;
  s.insert(a);
  int cnt = 1;
  while(1){
    cnt++;
    if(a%2==0) a/= 2;
    else a = 3*a+1;
    if(s.count(a)==0) s.insert(a);
    else{
      cout << cnt << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
count = 0
max_move = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
        if count > max_move:
            max_move = count
    else:
      count = 0
print(max_move)

Measured memory_bytes: 20512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 2000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

signed main(){
  int n,m;
  cin >> n >> m;
  int a[100000];
  int lc = 1;
  LOOP(i,n){
    cin >> a[i];
    if(a[i]<=0 || a[i]%2){
      int c = 0;
      int d = 1/c;
    }
    lc = lcm(a[i],lc);
    if(lc>m*2){
      cout << 0 << endl;
      return 0;
    }
  }
  // cout << lc << endl;
  LOOP(i,n){
    if((lc/a[i])%2==0){
      cout << 0 << endl;
      return 0;
    }
  }
  if(lc/2 <= m){
    cout << (m-lc/2)/lc+1 << endl;
  }

}


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

/*--- 異なるn個からr個の整数を取り出す組み合わせの数を返す ---*/
int combination(int n, int r)
{
    if(n<r) return (0);
    else if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int main(void) {
    int N,M; cin >> N >> M;
    int ans = combination(N,2) + combination(M,2);
    cout << ans << endl;
}

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

int main(){
    while(true){
        int N, M, r, q, t, n, m, s, ts, te, mm;
        vector<pair<int, pair<int, int> > > lg[10001];
        cin >> N >> M;
        if(!(N||M)) break;
        cin >> r;
        for(int i=0;i<r;++i){
            cin >> t >> n >> mm >> s;
            lg[mm].push_back(make_pair(t, make_pair(n, s)));
        }
        cin >> q;
        for(int i=0;i<q;++i){
            set<int> pc;
            int cnt=0;
            int start=0;
            cin >> ts >> te >> m;
            for(int j=0;j<lg[m].size();++j){
                if(lg[m][j].second.second == 1){
                    pc.insert(lg[m][j].second.first);
                }else{
                    pc.erase(lg[m][j].second.first);
                }
                if(lg[m][j].first < ts){
                    if(!pc.empty()){
                        start = ts;
                    }else{
                        start = 0;
                    }
                }else if(ts <= lg[m][j].first && lg[m][j].first <= te){
                    if(!pc.empty() && start==0){
                        start = lg[m][j].first;
                    }else if(pc.empty() && start!=0){
                        cnt += lg[m][j].first-start;
                        start = 0;
                    }
                }else if(lg[m][j].first > te){
                    if(start!=0) cnt += te-start;
                    break;
                }
            }
            cout << cnt << endl;
        }
    }
}

Measured memory_bytes: 1448
#include<stdio.h>
int main()
{
     int n;
     int answer=1;
    
    scanf("%d ",&n);
    
    while(n>0){
     if(n==64){
        answer=64;
        printf("%d",answer);
        break;
     }
      if(n==32){
        answer=32;
        printf("%d",answer);
        break;
     }
       if(n==16){
        answer=16;
        printf("%d",answer);
        break;
     } if(n==8){
        answer=8;
        printf("%d",answer);
        break;
     } if(n==4){
        answer=4;
        printf("%d",answer);
        break;
     } if(n==2){
        answer=2;
        printf("%d",answer);
        break;
     } if(n==1){
        answer=1;
        printf("%d",answer);
        break;
     }
      n--;
    } 
      
    return 0;
}

Measured memory_bytes: 128
#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 deb(x) cerr << #x <<": " << x << '\n';
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    fast_io();
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool flag = false;
    while(a > 0 && c > 0){
       // deb(c); deb(a);
        c -= b;
        if(c <= 0) {flag = true; break;}
        a -= d;
        if(a <= 0) break;
    }
    if(flag) cout << "Yes";
    else cout << "No";
    
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

struct BM {
  int L, R;
  vector<vector<int>> adj;
  BM(int L, int R) : L(L), R(R), adj(L+R) { }
  void add_edge(int u, int v) {
    adj[u].push_back(v+L);
    adj[v+L].push_back(u);
  }
  int maximum_matching() {
    vector<int> level(L), mate(L+R, -1);

    function<bool(void)> levelize = [&](){
      queue<int> Q;
      FOR(u, 0, L){
        level[u] = -1;
        if(mate[u] < 0) {
          level[u] = 0;
          Q.push(u); 
        }
      }
      while (!Q.empty()) {
        int u = Q.front();
        Q.pop();
        for(int w: adj[u]) {
          int v = mate[w];
          if(v < 0) return true;
          if(level[v] < 0) {
            level[v] = level[u] + 1;
            Q.push(v); 
          }
        }
      }
      return false;
    };
    function<bool(int)> augment = [&](int u) {
      for(int w: adj[u]) {
        int v = mate[w];
        if(v < 0 || (level[v] > level[u] && augment(v))){
          mate[u] = w;
          mate[w] = u;
          return true;
        }
      }
      return false;
    };
    int match = 0;
    while(levelize()) FOR(u, 0, L) if (mate[u] < 0 && augment(u)) match++;
    return match;
  }
};

int n;
vpii a, b;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  BM bm(n, n);
  FOR(i, 0, n){
    int x, y;
    cin >> x >> y;
    a.pb(pii(x, y));
  }
  FOR(i, 0, n){
    int x, y;
    cin >> x >> y;
    b.pb(pii(x, y));
  }
  FOR(i, 0, n)FOR(j, 0, n) if(a[i].fi < b[j].fi && a[i].se < b[j].se) bm.add_edge(i, j);
  cout << bm.maximum_matching() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  r(i,h*w){
    string s;
    cin >> s;
    if(s=="snuke"){
      char ch = 'A';
      ch+=i%w;
      cout << ch <<i/w+1<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int INFTY = (1<<20);
static const int MAX =10000;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra(){
    priority_queue<pair<int, int> > PQ;
    int d[MAX], color[MAX];
    
    for(int i = 0; i < n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;
    while(!PQ.empty() ){
        pair<int, int> f = PQ.top();PQ.pop();
        int u = f.second;
        color[u] = BLACK;
        
        if(d[u] < f.first * (-1))continue;
        
        for(int j = 0; j < adj[u].size(); j++){
            int v = adj[u][j].first;
            if(color[v] == BLACK)continue;
            if(d[v] > d[u] + adj[u][j].second){
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v] * (-1),v));
                color[v] = GRAY;
            }
        }
    }
    for(int i = 0; i < n; i++)cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
}
int main(){
    int k,c,u,v;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    return 0;
}



Measured memory_bytes: 3348
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var CYCLE = 1000000007
var CYCLE64 = int64(CYCLE)

func parseInt(s string) int {
	return int(parseInt64(s))
}

func parseInt64(s string) int64 {
	x, _ := strconv.ParseInt(s, 10, 64)
	return x
}

func readLine(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	return strings.TrimSuffix(s, "\n")
}

var N int
var K int64
var tmp [50]int

func sum(a []int) int {
	total := 0
	for j := 0; j < len(a); j++ {
		total += a[j]
		total %= CYCLE
	}
	return total
}

func mmul(a [][]int, b [][]int) {
	// fmt.Println("mmul(a, b)")
	// mprint(a)
	// fmt.Println("x")
	// mprint(b)
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			var tmp64 int64
			for k := 0; k < N; k++ {
				a64 := int64(a[i][k])
				b64 := int64(b[k][j])
				tmp64 = (tmp64 + a64*b64) % CYCLE64
			}
			tmp[j] = int(tmp64)
		}
		for j := 0; j < N; j++ {
			a[i][j] = tmp[j]
		}
	}
	// fmt.Println("=")
	// mprint(a)
	// fmt.Println("")
}

func mcreate() [][]int {
	result := make([][]int, N, N)
	for i := 0; i < N; i++ {
		result[i] = make([]int, N, N)
	}
	return result
}

func mcopy(a [][]int, b [][]int) {
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			a[i][j] = b[i][j]
		}
	}
}

func mprint(a [][]int) {
	for i := 0; i < N; i++ {
		fmt.Println(a[i])
	}
}

func mpow(a [][]int, p int64) {
	// fmt.Printf("mpow(%d) called\n", p)
	if p < 1 {
		panic("p must be >= 1")
	}
	if p == 1 {
		return
	}
	b := mcreate()
	mcopy(b, a)
	mmul(a, b)
	mpow(a, p/2)
	if p%2 != 0 {
		mmul(a, b)
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Sscan(readLine(reader), &N, &K)
	a := mcreate()
	for i := 0; i < N; i++ {
		for j, token := range strings.Fields(readLine(reader)) {
			a[i][j] = parseInt(token)
		}
	}

	mpow(a, K)

	total := 0
	for i := 0; i < N; i++ {
		total += sum(a[i])
		total %= CYCLE
	}
	fmt.Println(total)
}


Measured memory_bytes: 2048
#include<stdio.h>

int main(void)
{
	int H, W, i, j;

	while (1)
	{
		scanf("%d %d", &H, &W);
		if ((H == 0) && (W == 0)) break;
		for (i = 0; i < H; i++)
		{
			for (j = 0; j < W; j++)
			{
				if ((i+j) % 2 == 0 )
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


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

int main() {
  int N; cin >> N;
  string S; cin >> S; S = 'O' + S;
  vector<int> w(N + 2, 0), e(N + 2, 0);
  for (int i = 1; i <= N; ++i) w[i] = w[i - 1] + (S[i] == 'W');
  for (int i = N; i >= 1; --i) e[i] = e[i + 1] + (S[i] == 'E');
  int ans = 1e6;
  for (int i = 1; i <= N; ++i) ans = min(ans, w[i - 1] + e[i + 1]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3040
N = int(input())
a = [int(x) for x in input().split(" ")]

right = 0
cursum = 0
xor_res = 0

cnt = 0 

for left in range(N) :
    if left > right :
        right = left
    
    while right < N and left < N and cursum + a[right] == xor_res ^ a[right] :
        cursum += a[right]
        xor_res ^= a[right]
        right += 1
        
    cnt += right - left
    
    # decrement
    cursum -= a[left]
    xor_res ^= a[left]
    
    # print("DBG : ", left, right, cursum, xor_res, cnt)
    
print(cnt)

Measured memory_bytes: 23560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll t=1;
    //cin >> t;
    while(t--){
       ll x,n;
       cin >> x >> n;
       if(n==0){
           cout << x << endl;
           return 0;
       }
       ll arr[n],i;
       for(i=0;i<n;i++)
       cin >> arr[i];
       
       map<ll,ll>mp;
       for(i=0;i<n;i++)
       mp[arr[i]]++;
       if(mp[x]==0){
           cout << x << endl;
           return 0;
       }
       ll p=x,a,b,a1,b1;
       while(1>0){
           p--;
           if(mp[p]==0){
               a=p;
               break;
           }
       }
       p=x;
       while(1>0){
           p++;
           if(mp[p]==0){
               b=p;
               break;
           }
       }
       a1=abs(x-a);
       b1=abs(b-x);
       if(a1<=b1)
       cout << a << endl;
       else
       cout << b << endl;
    }
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int cyo;
	int hisi;
	
	hisi = 0;
	cyo = 0;
	
	while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
		
		if ((a * a) + (b * b) == (c * c)){
			cyo++;
		}
		
		else if (a == b){
			hisi++;
		}
	
	}
	printf("%d\n", cyo);
	printf("%d\n", hisi);
	return (0);
}

Measured memory_bytes: 596
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------
 
int main(void){
  ll N,A,B;cin>>N>>A>>B;
  ll ans;
  if(A%2==B%2)ans=(B-A)/2;
  else{
    ans=min(N-B+1+(B-A-1)/2,A-1+1+(B-A-1)/2);
  }
  cout<<ans;
  return 0;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int x,y;
    cin>>x>>y;

    map<int,int> gl;

    gl[1]=1;
    gl[3]=1;
    gl[5]=1;
    gl[7]=1;
    gl[8]=1;
    gl[10]=1;
    gl[12]=1;

    gl[4]=2;
    gl[6]=2;
    gl[9]=2;
    gl[11]=2;

    gl[2]=3;
    //cout <<fixed<<setprecision(16)<< << endl;

    if(gl[x] == gl[y])cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a*b==15)
    {
        cout<<"*"<<endl;
    }
    else if(a+b==15)
    {
        cout<<"+"<<endl;
    }
    else cout<<"x"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int x, y;
    do
    {
        scanf("%d %d", &x, &y);
        if (x > y)
        {
            printf("%d %d\n", y, x);
        }
        else if (x < y)
        {
            printf("%d %d\n", x, y);
        }else if (x != 0 || y != 0 && x == y)
        {
            printf("%d %d\n", x, y);
        }
        
    } while (x != 0 || y != 0);
    return 0;
}


Measured memory_bytes: 2048
#include <cstdio>

int n;

int main()
{
	scanf("%d", &n);
	for (int i = n; i <= 999; i++)
	{
		int a = i % 10, b = (i / 10) % 10, c = (i / 100);
		if (a == b && a == c) { printf("%d", i); break; }
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int x;
    cin>>x;
    cout<<x*x*x;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var A = GetLongs(N);

		long g = A.Aggregate((s, a) => a = gcd(s, a));
		var set = new HashSet<long>();
		for(long i = 0; i < N; i++)
		{
			long rest = A[i];
			for(long j = 2; j * j <= A[i]; j++)
			{
				if(rest % j != 0)
					continue;

				if(set.Contains(j))
				{
					WriteLine((g == 1) ? "setwise coprime" : "not coprime");
					return;
				}
				set.Add(j);

				while(rest % j == 0)
					rest /= j;			
			}
			if(rest > 1)
			{
				if(set.Contains(rest))
				{
					WriteLine((g == 1) ? "setwise coprime" : "not coprime");
					return;
				}
				set.Add(rest);
			}
		}
		WriteLine("pairwise coprime");
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 113020
n = int(input())
a = list(map(int, input().split()))
d = 0
for i in range(len(a)):
  if a[i] % 2 == 0:
    if a[i] % 3 != 0:
      if a[i] % 5 != 0:
        d = d + 1
if d == 0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
//Template
#include <bits/stdc++.h>
#define INF INT_MAX
#define MOD 100000007
#define MAX_E 1000000
#define MAX_V 1000000
using namespace std;

int V, E;
vector<int> adj[MAX_V];
int visited[MAX_V];
stack<int> stk;
void DFS(int u){
	visited[u]=2;
	int d=adj[u].size();
	for(int j=0; j<d; ++j){
		if(visited[adj[u][j]]==2){
			printf("Sandro fails.");
			exit(0);
		}
		if(visited[adj[u][j]]==0)
		DFS(adj[u][j]);
	}
	visited[u]=1;
	stk.push(u);
	return;
}
bool cmp(int i, int j){return i>j;}
int main(){
	scanf("%d%d", &V, &E);
	for(int i=0; i<E; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
	}
	for(int i=0; i<V; ++i){
		sort (adj[i].begin(), adj[i].begin()+adj[i].size(), cmp);
	}
	for(int i=0; i<V; ++i){
		if(!visited[i])DFS(i);
	}
	while(!stk.empty()){
		cout<<stk.top()<<endl;
		stk.pop();
	}
	return 0;
}
/*
8 9
1 4
1 2
4 2
4 3
3 2
5 2
3 5
8 2
8 6
*/


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

ll n,m,q;
ll a[505][505];
ll b[505][505];

int main(){
    cin >> n >> m >> q;
    for(ll i=0;i<m;i++){
        ll l,r;
        cin >> l >> r;
        a[r][l]++;
    }
    for(ll i=0;i<=500;i++){
        for(ll j=0;j<=500;j++){
            b[i][j+1]=b[i][j]+a[i][j];
        }
    }
    for(ll i=0;i<q;i++){
        ll c,d;
        cin >> c >> d;
        ll res=0;
        for(ll j=c;j<=d;j++){
            res+=b[j][d+1]-b[j][c];
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 7540
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

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

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

int main() {
	ll N, M;
	cin >> N >> M;
	vector<vector<vector<mint>>> dp(M + 1, vector<vector<mint>>(N + 1, vector<mint>(N + 1, 0)));

	dp[0][1][1] = 1;

	repn(i, M)repn(j, N)repn(k, N) {

		dp[i][j][k] += dp[i - 1][j][k - 1] * (N - k + 1);
		dp[i][j][k] += dp[i - 1][j][k] * (k - j);

		if (j == k) {
			repn(l, j) {
				dp[i][j][k] += dp[i - 1][l][k] * l;
			}
		}
	}

	cout << dp[M][N][N] << endl;


	
	
	system("PAUSE");

}

Measured memory_bytes: 217080