akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int h, w;
	while (cin >> h >> w, h){
		vector<vector<bool>> memo(h,vector<bool>(w,false));
		int x = 0,y=0;
		vector<string> vs(h);
		REP(i, h)
			cin >> vs[i];
		bool loop=false;
		while(vs[y][x]!='.'){
			if (memo[y][x]){
				loop = true;
				break;
			}
			memo[y][x] = true;
			if (vs[y][x] == '<')x--;
			else if (vs[y][x] == '^')y--;
			else if (vs[y][x] == '>')x++;
			else if (vs[y][x] == 'v')y++;
		}
		if (loop)
			cout << "LOOP" << endl;
		else
			cout << x << " " << y << endl;
	}
}

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

int main() {
  // 2x + 4y = Y, x+y=X
  // 2(X+y) = Y
  int x, y; cin >> x >> y;
  if (y&1 || y > 4*x || y < 2*x) cout << "No";
  else cout << "Yes";
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for(int i = a; i >=b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using ii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using pil = pair<int,ll>;
using vvi = vector<vi>;
using vpi = vector<ii>;

const int N = 100100;
ll mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int l, r , d;
    cin>>l>>r>>d;
    int x = (l -1 )/d;
    int y = (r)/d;
    cout<<y -x <<nl;  
    return 0;
}


Measured memory_bytes: 3648
def resolve():
    from collections import deque
    n, q = [int(i) for i in input().split()]
    P = [input().split() for _ in range(n)]
    que = deque(P)
    totalTime = 0
    while len(que) > 0:
        name, time = que.popleft()
        time = int(time)
        if time <= q:
            totalTime += time
            print(name, totalTime)
        else:
            totalTime += q
            que.append([name, str(time - q)])


resolve()



Measured memory_bytes: 19884
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) -1
print(L[K])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
bool check(string a, string b) {
  for (int i = 0; i < a.length(); i++) {
    if (a[i] != '?' && a[i] != b[i])
      return 0;
  }
  return 1;
}
int main() {
  IOS;
  string s, t;
  cin >> s >> t;
  vector<string> v;
  for (int i = 0; i < s.length() - t.length() + 1; i++) {
    if (check(s.substr(i, t.length()), t)) {
      // cout << s.substr(i, t.length()) << ' ' << t << endl;
      string tmp = s;
      for (int j = i; j < i + t.length(); j++)
        tmp[j] = t[j - i];
      // cout << tmp << endl;
      for (int j = 0; j < s.length(); j++)
        if (tmp[j] == '?')
          tmp[j] = 'a';
      v.pb(tmp);
    }
  }
  sort(all(v));
  if (v.empty()) {
    cout << "UNRESTORABLE" << endl;
  } else {
    cout << v[0] << endl;
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N; cin >> N;
    map<string, int> map;
    rep (i, 0, N) {
        string in; cin >> in;
        if (map.find(in) == map.end()) ++map[in];
    }

    cout << map.size() << endl;
}

Measured memory_bytes: 19128
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

static const int MOD=1e9+7;

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

    map<int, int> div;
    for (int i=2; i<=N; ++i) {
        int K=i;
        for (int j=2; j*j<=K; ++j) {
            while (K % j == 0) {
                ++div[j];
                K /= j;
            }
        }

        if (K > 1) ++div[K];
    }

    long long res=1;
    for (const auto &item: div)
        (res *= item.second+1) %= MOD;

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef pair<ld,ll> dlP;

#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ld LINF=101001001001001.0;
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
ll n;
ll x[1010],y[1010],r[1010];
vector<pair<ll,ld>> to[1010];
vector<ld> d(1010);
void Dijkstra(){
    rep(i,1010)d[i]=LINF;
    d[n]=0;
    priority_queue<dlP,vector<dlP>,greater<dlP>> pq;
    pq.push({0.0,n});
    while(pq.size()){
        ll nowp=pq.top().se;
        ld nowd=pq.top().fi;
        pq.pop();
        if(nowd>d[nowp])continue;
        for(auto nxt: to[nowp]){
            ll nxtp=nxt.fi;
            ld nxtd=nxt.se+nowd;
            //cout<<nxtp<<" "<<nxtd<<endl;
            if(chmin(d[nxtp],nxtd)){
                pq.push({nxtd,nxtp});
            }
        }
    }
    return;
}
ld f(int s,int t){
    ll dx=abs(x[t]-x[s]);
    ll dy=abs(y[t]-y[s]);
    ld res=sqrt(ld(dx*dx)+ld(dy*dy));
    if(s!=n||s!=n+1)res-=(ld)r[s];
    if(t!=n||t!=n+1)res-=(ld)r[t];
    res=max(res,(ld)0.0);
    return res;
}
int main(){
    ll xs,ys,xt,yt;cin>>xs>>ys>>xt>>yt;
    cin>>n;
    rep(i,n)cin>>x[i]>>y[i]>>r[i];
    x[n]=xs;y[n]=ys;
    x[n+1]=xt;y[n+1]=yt;
    rep(i,n+2){
        for(int j=i+1;j<n+2;j++){
            to[i].pb({j,f(i,j)});
            to[j].pb({i,f(i,j)});
        }
    }
    Dijkstra();
    ld ans=d[n+1];
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 41872
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
int main()
{
    fio;
    int n,k;
    cin>>n>>k;
    vector<ll> v1,v2;
    ll a1;
    loop(i,0,n)
    {
        cin>>a1;
        v1.pb(a1);
    }
    loop(i,1,n)
    {
        if(v1[i]!=1)
        v1[i]+=v1[i-1];
        else
        {
            v1[i]+=v1[i-1];
            v1[i]--;
        }
    }
    v2 = v1;
    for(int i=k,j=0;i<n;i++,j++)
    {
     ll p = v2[i]-v2[j];
     //cout<<p<<" "<<v2[i]<<" "<<v2[j]<<" ";
     if(v1[i-1]<p)
        cout<<"Yes\n";
     else
        cout<<"No\n";
        v1[i] = p ;
    }
    return 0;
}


Measured memory_bytes: 6372
# include <cstdio>
# include <vector>

using namespace std;

const int MAX_N = 1e5 + 10;

int n, m;

bool u[MAX_N];
int x[MAX_N];

vector <int> crr;
vector <pair <int, int>> v[MAX_N];

void dfs (int c)
{
    crr.push_back (c);
    u[c] = true;
    for (int i = 0; i < (int) v[c].size (); i ++)
        if (!u[v[c][i].first])
        {
            x[v[c][i].first] = x[c] + v[c][i].second;
            dfs (v[c][i].first);
        }
}

int main ()
{
    int i, j, k, l, r, d;
    scanf ("%d%d", &n, &m);
    for (i = 0; i < m; i ++)
    {
        scanf ("%d%d%d", &l, &r, &d);
        v[l].push_back ({r, d});
        v[r].push_back ({l, -d});
    }

    for (i = 1; i <= n; i ++)
        if (!u[i])
        {
            crr.clear ();
            dfs (i);
            for (j = 0; j < (int) crr.size (); j ++)
                for (k = 0; k < (int) v[crr[j]].size (); k ++)
                    if ((x[crr[j]] + v[crr[j]][k].second) != x[v[crr[j]][k].first])
                    {
                            printf ("No\n");
                            return 0;
                    }
        }

    printf ("Yes\n");

    return 0;
}


Measured memory_bytes: 12544
n,m = map(int,input().split())
d={}
for i in range(m):
  p,s=input().split()
  if p in d.keys():
    d[p].append(s)
  else:
    d[p]=[s,]
ac=0
wa=0
for k,v in d.items():
  if "AC" in v:
    for i in v:
      if i=="WA":
        wa=wa+1
      else:
        ac=ac+1
        break

print(ac,wa)

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

int main (){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int L = a + b;
  int R = c + d;
  
  if ( L > R) puts (" Left ");
  else if ( L == R) puts (" Balanced ");
  else puts (" Right ");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x; }
ll lcm(ll x, ll y) { return x/gcd(x, y)*y; }

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

  int n; cin >> n;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];

  ll ans = 1;
  rep(i, n) ans = lcm(ans, t[i]);
  cout << ans << '\n';
  return 0;
}


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

rou = [[] for i in range(n)]
for i in range(m):
	a, b = map(int, input().split())
	rou[a-1].append(b-1)
	rou[b-1].append(a-1)
for i in rou[0]:
	for j in rou[i]:
		if j == n-1:
			print("POSSIBLE")
			exit()
print("IMPOSSIBLE")

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

mod = int(1e+9 + 7)

rui = 0
for i in range(N):
    rui = (rui + A[i])%mod
    
answer = 0
for i in range(N-1):
    rui = (rui - A[i])%mod
    answer = (answer + rui * A[i])%mod
    
print(answer)

Measured memory_bytes: 94056
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define do double
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mkp make_pair

typedef vector <int> vi;
typedef map <int,int> mii;
typedef set <int> si;
typedef pair <int,int> pii;
typedef unordered_map <int,int> um;
typedef unordered_set <int> us;
typedef multiset <int> ms;
typedef vector < pair <int,int> > vpii;
// Driver code 
int main() 
{ 
    int n,m,mx=0;
    cin>>n>>m;
    char a[n+1][m+1];
    ll dp[n+1][m+1]={};
    loop(i,n)
        loop(j,m)
         cin>>a[i+1][j+1];
    dp[1][1]=1;
    loop(i,n)
    {
        loop(j,m)
        {
            if(a[i+1][j+1]=='.' && (j!=0 || i!=0))
            { 
                dp[i+1][j+1]= (dp[i][j+1]%mod + dp[i+1][j]%mod)%mod;
            }
        }
    }
    cout<<dp[n][m]<<"\n";
} 



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

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];

    int ans = 0;
    while (!all_of(h, h + n, [](int x) { return x == 0; })) {
        bool find = false;
        rep(i, n) {
            if (h[i] != 0)
                h[i]--, find = true;
            else if (find)
                break;
        }
        ans++;
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n,f=0,j;
    cin>>n;j=n/2;
    string s;cin>>s;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]==s[j])
           {f++;j++;}
        else
            break;
    }
    if(f==n/2&&j==n)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main(){
  string x, y, z;
  while(cin >> x >> y >> z){

    int p = 0;
    int pred =  0, pgreen = 1;
    char ch = y[0];

    string ret;

    while(p < z.size()){
      if( ch == z[p]){
        ch = x[pred++];
        p++;
      }else{
        ret += ch;
        ch = y[pgreen++];
      }
    }
    ret += ch + y.substr(pgreen);
    cout << ret << endl;
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  int si;
  int count;
  
  cin >> si;
  a=si/100;
  b=(si-a*100)/10;
  c=(si-a*100-b*10);
  
  if (a==1)
  {
    count=count+1;
  }
  if (b==1)
  {
    count=count+1;
  }
  if (c==1)
  {
    count=count+1;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/


int main(void) {
	int r, d, x; cin >> r >> d >> x;

	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}

	return 0;
}


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

char fie[1001][1001];
int H,W,N;
int memo[1001][1001];
char S[1000001];
int Ds[1000001][4];

int dx[]={0,1,0,-1};//R -> +1 , L -> +1
int dy[]={-1,0,1,0};

int sx,sy,gx,gy;

struct state{
  int x,y,c;
  bool operator>(const state &st) const{
    return c > st.c;
  }

};

bool check( int x,int y,int nc){
  if( x < 0 || y < 0 || x >= W || y >= H ) return false;
  if( fie[x][y] == '#' ) return false;
  if( memo[x][y] == -1 ) return true;
  if( memo[x][y] <= nc ) return false;
  return true; 
}



bool bfs(){

  memset(memo,-1,sizeof(memo));

  priority_queue<state,vector<state>,greater<state> > q;

  q.push( (state){sx,sy,0} );
  memo[sx][sy] = 0;
  while( !q.empty() ){
    state p = q.top(); q.pop();
    int x = p.x;
    int y = p.y;
    int c = p.c;

    //  cout << x<< " " << y << " "<< c << endl;

    for(int i=0;i<4;i++){
      int nd = i;
      int nc = Ds[c][nd];
      if( nc > N ) continue;
      int nx = x+dx[nd];
      int ny = y+dy[nd];
      if( check(nx,ny,nc) ){
	q.push( (state){nx,ny,nc} );
	memo[nx][ny] = nc;
      }
    }
  }
  if( memo[gx][gy] == -1 )
    return false;
  return true;
}

int main(){
  while(cin >> H >> W >> N && (H||W||N) ){
    for(int i=1;i<=N;i++){
      cin >> S[i];
    }
    S[0] = 0;
    int dnc = 0;
    for(int i=1;i<=N;i++){
      if( S[i] == 'L' ){
	dnc+=3;	 
      } else {
	dnc++;
      }
      dnc %= 4;
      S[i] = (char)dnc;
    }
    
    int dc[4] = {N+1,N+1,N+1,N+1};
    for(int i=N;i>-1;i--){
      dc[(int)S[i]] = i;
      for(int j=0;j<4;j++){
	Ds[i][j] = dc[j];
	//	printf("%d, %d  %d\n",i-1,j,(int)Ds[i-1][j]);
      }
    }

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> fie[j][i];
	if( fie[j][i] == 'G' ){
	  gx=j;
	  gy=i;
	}
	if( fie[j][i] == 'S' ){
	  sx = j;
	  sy = i;
	}
      }
    }
    
    if( bfs() ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 8880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    char A='A',Z='Z',inp;
    cin>>inp;
    if(inp>=A&&inp<=Z)
    {
        cout<<"A\n";
    }
    else
    {
        cout<<"a\n";
    }
    return 0;
    
}

Measured memory_bytes: 3560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
int a[500][500];
int b[500][500];
int p[100000];
int q[100000];
int main(void){
    int n, m, Q;
    scanf("%d %d %d", &n, &m, &Q);
    for(int i = 0;i < n;i++)for(int j = 0;j < n;j++)a[i][j] = 0;
    for(int i = 0;i < m;i++){
        int l, r;
        scanf("%d %d", &l, &r);
        l--;
        r--;
        a[l][r]++;
    }
    for(int i = 0;i < Q;i++){
        int pp, qq;
        scanf("%d %d", &pp, &qq);
        pp--;
        qq--;
        p[i] = pp;
        q[i] = qq;
    }
    /*for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++)printf("%d ", a[i][j]);
        printf("\n");
    }*/
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            int ab = 0;
            for(int k = i;k <= j;k++)for(int l = k;l <= j;l++)ab += a[k][l];
            b[i][j] = ab;
        }
    }
    /*for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++)printf("%d ", b[i][j]);
        printf("\n");
    }*/
    for(int i = 0;i < Q;i++)printf("%d\n", b[p[i]][q[i]]);
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <chrono>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << setw(2) << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白など(ホワイトスペース)を含む入力
// cin >> ws; でそこまでに入力ストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int q;
    cin >> q;
    vector<string> s1(q), s2(q);
    for(int i=0; i<q; i++){
        cin >> s1[i] >> s2[i];
    }

    vector<int> ans(q);
    for(int i=0; i<q; i++){
        int s1_size = s1[i].size();
        int s2_size = s2[i].size();
        
        vector<vector<int>> dp(s1_size, vector<int>(s2_size, 0));
        // 初期化
        bool flag_same = false;
        for(int j=0; j<s1_size; j++){
            if(s1[i][j] == s2[i][0] && !flag_same){
                flag_same = true;
            }
            if(flag_same) dp[j][0] = 1;
            else dp[j][0] = 0;
        }
        flag_same = false;
        for(int j=0; j<s2_size; j++){
            if(s2[i][j] == s1[i][0] && !flag_same){
                flag_same = true;
            }
            if(flag_same) dp[0][j] = 1;
            else dp[0][j] = 0;
        }

        // 計算
        for(int j=1; j<s1_size; j++){
            for(int k=1; k<s2_size; k++){
                if(s1[i][j] == s2[i][k]){
                    dp[j][k] = min(dp[j-1][k-1], min(dp[j-1][k], dp[j][k-1])) + 1;
                }else{
                    dp[j][k] = max(dp[j-1][k], dp[j][k-1]);
                }
            }
        }
        // LOOPD(i);
        // for(int j=0; j<s1_size; j++){
        //     DUMPL(dp[j]);
        // }
        // cout << "   ";
        // for(int j=0; j<s2_size; j++){
        //     cout << setw(2) << s2[i][j] << ' ';
        // }
        // cout << endl;

        // for(int j=0; j<s1_size; j++){
        //     cout << setw(2) << s1[i][j] << ' ';
        //     for(int k=0; k<s2_size; k++){
        //         cout << setw(2) << dp[j][k] << ' ';
        //     }
        //     cout << endl;
        // }

        ans[i] = dp.back().back();
    }
    
    // DUMP(ans);
    for(int i=0; i<q; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 6792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;

int main(int argc, char *argv[])
{
    int q, cnt, tmp;
    string n;
    vector<int>::iterator itr;
    cin >> q;
    while (cin >> n, q--) {
        vector<int> cache;
        for (cnt = 0;; ++cnt) {
            if (n.length() == 1)
                break;
            int kmax = 0;
            for (int i = 1; i < n.length(); ++i) {
                tmp = atoi(n.substr(0, i).c_str()) * atoi(n.substr(i).c_str());
                kmax = max(tmp, kmax);
            }
            itr = find(cache.begin(), cache.end(), kmax);
            if (itr != cache.end()) {
                cnt = -1;
                break;
            }
            else
                cache.push_back(kmax);
            stringstream ss;
            ss << kmax;
            n = ss.str();
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=110;
char s[N]; LL k,len;
int main(){
	scanf("%s%lld",s,&k); len=strlen(s);
	bool flag=0;
	for(LL i=1; i<len; ++i)
		if(s[i]!=s[i-1])flag=1;
	if(!flag)return printf("%lld",len*k/2),0;
	if(s[len-1]!=s[0]){
		LL ans=0;
		for(LL i=0; i<len; ){
			LL j=i;
			while(j<len&&s[j]==s[i])++j;
			ans+=(j-i)/2;
			i=j;
		}
		printf("%lld",ans*k);
	}else{
		LL ans=0;
		LL len1,len2;
		for(len1=0; s[len1]==s[0]; ++len1);
		for(len2=len-1; s[len2]==s[len-1]; --len2);
		for(LL i=len1; i<=len2;){
			LL j=i;
			while(j<=len2&&s[j]==s[i])++j;
			ans+=(j-i)/2;
			i=j;
		}
		printf("%lld",ans*k+(len1+len-len2-1)/2*(k-1)+len1/2+(len-len2-1)/2);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    ll n, c; cin >> n >> c;
    vll x(n+2,0), v(n+1,0);
    REP(i,n+1) cin >> x[i] >> v[i];
    x[n+1] = c;
    vll sum_v(n+2,0);
    REP(i,n+1) sum_v[i] = sum_v[i-1] + v[i];
    sum_v[n+1] = sum_v[n];
    vll f_a(n+1,0);
    REP(i,n+1) {
        f_a[i] = max(f_a[i-1],sum_v[i]-x[i]);
    }
    vll f_b(n+1,0);
    REP(i,n+1) {
        f_b[i] = max(f_b[i-1],(sum_v[n]-sum_v[n-i])-(c-x[n-i+1]));
    }
    ll ans = 0;
    for (int x_b = n+1; x_b >= 0; x_b--) {
        ll tmp = f_a[x_b-1]+(sum_v[n]-sum_v[x_b-1])-(c-x[x_b]);
        chmax(ans,tmp-(c-x[x_b]));
    }
    for (int x_a = 0; x_a <= n; x_a++) {
        ll tmp = f_b[n-x_a]+sum_v[x_a]-x[x_a];
        chmax(ans,tmp-x[x_a]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
time = []
last = 0
amari = 10
flg = True
sum = 0

for i in range(5):
    time.append(int(input()))

for i in range(5):
    temp = time[i]%10
    if temp > 0 and temp < amari:
        amari = temp
        last = time[i]

for i in range(5):
    if time[i] == last and flg == True:
        sum += last
        flg = False
    else:
        sum += time[i]
        if time[i]%10 != 0:
            sum += 10-(time[i]%10)
print(sum)

Measured memory_bytes: 3064
import sys
n, m = map(int, input().split())
isExist = True
isExist2=True
li2 = [[''] for i in range(n)]
for i in range(m):
    s, c = map(int, input().split())
    if (li2[s - 1][0] != '' and li2[s - 1][0] != c):
        isExist = False
    elif(s == 1 and c == 0):
            isExist2 = False
    else:
        li2[s - 1][0] = c
ans=''
if (not isExist):
        print(-1)
        sys.exit()
if (not isExist2):
    if (n == 1):
        print(0)
        sys.exit()
    else:
        print(-1)
        sys.exit()
for i in range(n):
    if (li2[0][0] == ''):
        li2[0][0]=1
    if (li2[i][0] == ''):
        li2[i][0] = 0
for i in range(n):
    ans += str(li2[i][0])
if (n == 1 and m == 0):
    ans=0
print(int(ans))

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

struct status{
	char l[21];
	double ef;
};

int cmp(const void* a,const void * b){
	struct status *s1 = (struct status *)a;
	struct status *s2 = (struct status *)b;
	if(s1->ef > s2->ef)
		return 0;
	else if(s1->ef < s2->ef)
		return 1;
	else
		return strcmp(s1->l,s2->l);
}

int main(void){
	int n, a, b, c, d, e, f, p, m, s, i, j;
	struct status ss[50];
	while(1){
		scanf("%d%*c",&n);
		if(!n) break;
		for(i = 0;i < n;i++){
			for(j = 0;(ss[i].l[j] = getchar()) != ' ';j++);
			ss[i].l[j] = '\0';
			scanf("%d%d%d%d%d%d%d%d%d%*c",&p,&a,&b,&c,&d,&e,&f,&s,&m);
			ss[i].ef = (double)(m * f * s - p) / (a + b + c + (d + e) * m);
		}
		qsort(ss,n,sizeof(ss[0]),cmp);
		for(i = 0;i < n;i++)
			printf("%s\n",ss[i].l);
		printf("#\n");
	}
	return 0;
}

Measured memory_bytes: 1060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		//int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] NMK = Console.ReadLine().Split(' ');
		int a = int.Parse(NMK[0]);
		int b = int.Parse(NMK[1]);
		int c = int.Parse(NMK[2]);

		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
		//Console.WriteLine((a+b+c) + " " + s);
		Console.WriteLine(c + " " + a + " " + b);
	}
}


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

int		main()
{
	int		N, A;
	int		*boss;

	scanf("%d\n", &N);
	boss = (int *)calloc((N + 1), sizeof(int));
	for (int i = 0; i<(N - 1);i++)
	{
		scanf("%d ", &A);
		boss[A]++;
	}
	for (int i = 1; i<=N;i++)
	{
 		printf("%d\n", boss[i]);
	}
	return (0);
}

Measured memory_bytes: 2460
import sys

n, q = map(int, sys.stdin.readline().split())
s = sys.stdin.readline()

elist = [0] * (n+1)
for i in range(n - 1):
    elist[i + 2] = elist[i + 1] + (1 if 'AC' == s[i:i+2] else 0)

for i in range(q):
    l, r = map(int, sys.stdin.readline().split())
    print(elist[r] - elist[l])


Measured memory_bytes: 7916
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, K; cin >> N >> K;

  ll result = pow(N/K, 3);
  if (K%2==0) result += pow((N+K/2)/K, 3);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, n;
	cin >> h >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int sum = 0;
	rep(i, n) sum += a[i];
	if (sum >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
}


Measured memory_bytes: 256
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import math
def resolve():
    N,M=pin()
    print(math.ceil((N-1)/(M-1)))

#%%submit!
resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>
#include <unordered_map>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    ll n,a,b,c;
    cin >> n >> a >> b >> c;
    bool ab = 0, bc = 0, ac = 0;
    vector<string> op(n);
    for(int i = 0; i < n; i++){
        string t;
        cin >> t;
        op[i] = t;
    }

    vector<char> ans(n);
    for(int i = 0; i < n; i++){
        if(op[i] == "AB"){
            if(a == b && c == 0){
                ab = false;
                for(int j = i+1; j < n; j++){
                    if(op[j] == "AC") break;
                    else if(op[j] == "BC"){
                        ab = true;
                        break;
                    }
                }
            } else {
                ab = a>b?true:false;
            }
            if(ab){
                ans[i] = 'B';
                a--;
                b++;
            } else {
                ans[i] = 'A';
                a++;
                b--;
            }
        } else if(op[i] == "BC"){
            if(b == c && a == 0){
                bc = false;
                for(int j = i+1; j < n; j++){
                    if(op[j] == "AB") break;
                    else if(op[j] == "AC"){
                        bc = true;
                        break;
                    }
                }
            } else {
                bc = b>c?true:false;
            }
            if(bc){
                ans[i] = 'C';
                b--;
                c++;
            } else {
                ans[i] = 'B';
                b++;
                c--;
            }
        } else {
            if(a == c && b == 0){
                ac = false;
                for(int j = i+1; j < n; j++){
                    if(op[j] == "BC") break;
                    else if(op[j] == "AB"){
                        // cout << "i:" << i << " in" << endl;
                        ac = true;
                        break;
                    }
                }
            } else {
                ac = c>a?true:false;
            }

            if(ac){
                ans[i] = 'A';
                a++;
                c--;
            } else {
                ans[i] = 'C';
                a--;
                c++;
            }
        }

        if(a < 0 || b < 0 || c < 0){
            // cout << "i:" << i << " " << a << "," << b << "," << c << endl;
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    // cout <<  a << "," << b << "," << c << endl;
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long LL;

const int nmax = 200005; const LL inf = 2e18; const int mod = 1000000009;

int N,a[nmax],v[nmax],cnt,nr;

int main(){
//   #ifndef GLOBAL_JUDGE
//      freopen("txt.in","r",stdin);
//      freopen("txt.out","w",stdout);
//   #endif // GLOBAL_JUDGE
   int i;
   cin >> N;
   for(i = 1; i <= N; ++i)
      cin >> a[i],v[a[i]]++;
   sort(a+1,a+N+1);
//   for(i = 1; i <= N; ++i)
//      cout << a[i]<<' ';
   cnt = N;
   for(i = 1; i <= N; ++i)
      if(v[a[i]]>1){
         if(v[a[i]] % 2 == 0)++nr,cnt-=(v[a[i]]-2),v[a[i]]=0;
         else cnt-=v[a[i]],v[a[i]] = 0,++cnt;
   }
   N = cnt;
//   cout << N << ' '<<nr << '\n';
   if(nr%2 == 0)N-=nr;
   else{
      N-=(nr+1);
   }
   cout << N << '\n';
   return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	int N, i, ans = 0;
	scanf("%d", &N);
	while (N--) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		ans += t2 - t1 + 1;
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val g = Array(n + 1) { mutableListOf<Int>() }
    val degree = IntArray(n + 1)

    repeat(n - 1 + m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        g[a].add(b)
        degree[b]++
    }

    val sorted = mutableListOf<Int>()
    val queue = ArrayDeque<Int>()
    for (v in 1..n) {
        if (degree[v] == 0) {
            queue.addLast(v)
        }
    }

    while (queue.isNotEmpty()) {
        val v = queue.removeFirst()
        for (u in g[v]) {
            degree[u]--
            if (degree[u] == 0) queue.addLast(u)
        }
        sorted.add(v)
    }

    val rev = IntArray(n + 1)
    for ((i, v) in sorted.withIndex()) {
        rev[v] = i
    }

    val ans = IntArray(n + 1) { sorted[0] }
    ans[sorted[0]] = 0
    for ((a, bs) in g.withIndex()) {
        for (b in bs) {
            if (rev[ans[b]] < rev[a]) ans[b] = a
        }
    }

    println(ans.slice(1..n).joinToString("\n"))
}


Measured memory_bytes: 86596
#include<bits/stdc++.h>
using namespace std;
const int md=1000000007;
int n,f[100005];
vector<pair<int,int> >v1,v2;
vector<pair<int,pair<int,int> > >g;
int fnd(int x){return f[x]==x?x:f[x]=fnd(f[x]);}
bool uni(int x,int y)
{
	x=fnd(x);
	y=fnd(y);
	if(x==y)return false;
	f[x]=y;
	return true;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v1.push_back(make_pair(a,i));
		v2.push_back(make_pair(b,i));
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	g.clear();
	for(int i=0;i<n-1;i++)
	{
		int a=v1[i].first;
		int b=v1[i+1].first;
		int c=v1[i].second;
		int d=v1[i+1].second;
		g.push_back(make_pair(b-a,make_pair(c,d)));
	}
	for(int i=0;i<n-1;i++)
	{
		int a=v2[i].first;
		int b=v2[i+1].first;
		int c=v2[i].second;
		int d=v2[i+1].second;
		g.push_back(make_pair(b-a,make_pair(c,d)));
	}
	sort(g.begin(),g.end());
	for(int i=1;i<=n;i++)f[i]=i;
	int t=n-1;
	long long ans=0;
	for(int i=0;i<g.size();i++)
	{
//		cout<<g[i].second.first<<" "<<g[i].second.second<<" "<<g[i].first<<endl;
		if(uni(g[i].second.first,g[i].second.second))
		{
			ans+=g[i].first;
			t--;
		}
		if(t==0)
		{
			printf("%lld\n",ans);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 7144
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	for i := 0; i < n; i++ {
		a := aa[i]
		if a%2 == 1 {
			continue
		}
		if a%3 != 0 && a%5 != 0 {
			fmt.Fprintln(writer, "DENIED")
			return
		}
	}
	fmt.Fprintln(writer, "APPROVED")
}


Measured memory_bytes: 640
N, M = input().strip().split()
n, k = [int(N), int(M)]
a = list(map(int, input().strip().split()))
le = 0
ri = 10000000000
while ri - le > 1:
    mid = (le + ri)// 2
    num = 0
    for i in a:
        num += (i-1)// mid
    if num <= k:
        ri = mid
    else:
        le = mid
print(ri)


Measured memory_bytes: 30772
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n;
	cin>>n;
	vector<ll> a(n),sum(n,0LL);
	for(int i = 0; i < n; i++){
		cin>>a[i];
		sum[i] = (i==0?0:sum[i-1]) + a[i];
	}

	vector<int> half_left(n,0);
	int half_pos = 0;
	for(int i = 1; i < n-2; i++){
		ll P = sum[half_pos];  // P = 0 ~ half_pos
		ll Q = sum[i] - sum[half_pos]; //Q = half_pos+1 ~ i
		while(abs(P + a[half_pos+1] - (Q-a[half_pos+1])) < abs(P-Q)){
			half_pos++;
			P = sum[half_pos];
			Q = sum[i] - sum[half_pos];
		}

		half_left[i] = half_pos;
	}

	vector<int> half_right(n,0);
	half_pos = n-1;
	for(int i = n-3; i >=1; i--){
		ll R = sum[half_pos-1] - sum[i];  // R = i ~ half_pos-1
		ll S = sum[n-1] - sum[half_pos-1];	// S = half_pos ~ n-1
		while(abs(R - a[half_pos-1] - (S + a[half_pos-1]))< abs(R-S)){
			half_pos--;
			R = sum[half_pos-1] - sum[i];
			S = sum[n-1] - sum[half_pos-1];
		}

		half_right[i] = half_pos;
	}

	// for(int i = 1; i < n-2; i++){
	// 	cout << i << " " << a[half_left[i]] << " "<<a[half_right[i]] << endl;
	// }

	ll ans = INF*INF;
	for(int i = 1; i < n-2; i++){
		ll P = sum[half_left[i]], Q = sum[i] - sum[half_left[i]];
		ll R = sum[half_right[i]-1] - sum[i], S = sum[n-1] - sum[half_right[i]-1];

		ll ma = max(max(P,Q),max(R,S));
		ll mi = min(min(P,Q),min(R,S));
		ans = min(ans,abs(ma-mi));
	}

	cout<<ans<<endl;

	return 0;
}

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

int main(){
  int a,b,c,d,e;
  int cntTime = 0;
  int tmp;
  int max = 0;
  cin >> a >> b >> c >> d >> e;
  
  tmp = 10 - (a % 10);
  if(tmp == 10){
    cntTime += a;
  }else{
    cntTime += a + tmp;
    if(max < tmp) max = tmp;
  }  
  
  tmp = 10 - (b % 10);
  if(tmp == 10){
    cntTime += b;
  }else{
    cntTime += b + tmp;
    if(max < tmp) max = tmp;
  }  
  
  tmp = 10 - (c % 10);
  if(tmp == 10){
    cntTime += c;
  }else{
    cntTime += c + tmp;
    if(max < tmp) max = tmp;
  }  
  
  tmp = 10 - (d % 10);
  if(tmp == 10){
    cntTime += d;
  }else{
    cntTime += d + tmp;
    if(max < tmp) max = tmp;
  }  
  
  tmp = 10 - (e % 10);
  if(tmp == 10){
    cntTime += e;
  }else{
    cntTime += e + tmp;
    if(max < tmp) max = tmp;
  }
  
  cout << cntTime - max;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
H=[int(i) for i in input().split()]
A=[0]*M
B=[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())
D=[i+1 for i in range(N)]
C=[]
for i in range(M):

    if(H[A[i]-1]>H[B[i]-1]):

        C.append(B[i])

    elif(H[A[i]-1]<H[B[i]-1]):

        C.append(A[i])
    else:

        C.append(A[i])
        C.append(B[i])

G=list(set(D)-set(C))
print(len(G))


Measured memory_bytes: 117044
n = int(input())
l = list(map(int, input().split()))

if len(set(l)) < 3:
    print("0")
    exit()

result = []
for i in range(len(l)):
  for j in range(i + 1, len(l)):
    for k in range(j + 1, len(l)):
        if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
            if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                result.append([l[i], l[j], l[k]])
print(len(result))

Measured memory_bytes: 25372
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <bitset>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vl = vector<ll>;
using vb = deque<bool>;


#define FOR(i,N) for(int i=0;i<N;i++)
#define FOR2(i, N) for(int i=1;i<=N;i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

//cin.tie(nullptr);
//ios_base::sync_with_stdio(false);
//cout << fixed << setprecision(10);
//double pi = 3.141592653589793238;


int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int N; int Q;
	cin >> N >> Q;

	vector<vector<int> > e(N + 1);
	FOR(i, N-1) {
		int a, b;
		cin >> a >> b;
		e[a].pb(b);
		e[b].pb(a);
	}

	vb visited(N + 1);
	vi plus(N + 1);
	vi ans(N + 1);

	FOR(i, Q) {
		int a, b;
		cin >> a >> b;
		plus[a] += b;
	}

	ans[1] = plus[1];
	visited[1] = true;

	stack<pair<int, int>> s;
	s.push(mp(1,plus[1]));

	while (s.size()) {
		int v = s.top().first;
		int acc = s.top().second;
		s.pop();

		for (auto x : e[v]) {
			if (!visited[x]) {
				visited[x] = true;
				ans[x] = acc + plus[x];
				s.push(mp(x, acc + plus[x]));
			}
		}
	}


	FOR2(i, N) {
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 17396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    ll n,k;
    cin>>n>>k;
    if(k>(n-1)*(n-2)/2) cout<<-1<<endl;
    else{
        ll m=n-1+(n-1)*(n-2)/2-k;
        cout<<m<<endl;
        int count=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                cout<<i<<" "<<j<<endl;
                count++;
                if(count>=m) break;
            }
            if(count>=m) break;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
using ll=long long int;

int main(){
    int A,B;
    cin >> A >> B;
    if(A<=8&&B<=8){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll dp[110000][13];

int main(){
  string S;
  cin>>S;
  ll N=S.size();
  dp[0][0]=1;
  int multi=1,temp,hairetu,flag=1;
  int count=0;
  for(int i=N-1;i>=0;i--,multi=multi*10%13,flag=1){
    hairetu=N-1-i+1;
    if(S[i]=='?') flag=0;
    else temp=S[i]-'0';
    for(int j=0;j<13;j++){
      if(flag==1){
        if(j==0) temp=temp*multi%13;
        dp[hairetu][(j+temp)%13]+=dp[hairetu-1][j];
        dp[hairetu][(j+temp)%13]%=MOD;
      }else{
        for(int k=0;k<10;k++){
          count++;
          temp=k*multi%13;
          dp[hairetu][(j+temp)%13]+=dp[hairetu-1][j];
          dp[hairetu][(j+temp)%13]%=MOD;
        }
      }
    }
  }
  cout<<dp[N][5]<<endl;
}


Measured memory_bytes: 10688