akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int mt[3][3];

int32_t main(){
	ios::sync_with_stdio(0);	
	for(int i=0; i<3; ++i)
		for(int j=0; j<3; ++j)
			cin >> mt[i][j];
	int n;
	cin >> n;
	set<int> st;
	for(int i=0; i<n; ++i) {
		int x;
		cin >> x;
		st.insert(x);
	}	
	bool can = false;
	for(int i=0; i<3; ++i){
		bool res = true;
		for(int j=0; j<3; ++j) 
			if(st.find(mt[i][j])==st.end()) 
				res=false;
		if(res) can = true;
	}
	for(int j=0; j<3; ++j){
		bool res = true;
		for(int i=0; i<3; ++i) 
			if(st.find(mt[i][j])==st.end()) res=false;
		if(res) can = true;
	}
	bool res = true;
	for(int i=0; i<3; ++i) 
		if(st.find(mt[i][i])==st.end()) res=false;
	if(res) can = true;
	res = true;
	for(int i=0; i<3; ++i) 
		if(st.find(mt[i][2-i])==st.end()) res=false;
	if(res) can = true;
	
	if(can)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n;
string s="";
void dfs(string s,char mx)
{
    if(s.length()==n)
     cout<<s<<"\n";
     else
     {
         for(char c='a';c<=mx;c++)
         { //s+=c;
            if(c==mx)
             dfs(s+c,mx+1);
             else
              dfs(s+c,mx);
         }
     }
}

int main()
{ 
  cin>>n;
  if(n==1)
  {
      cout<<'a';
      return 0;
  }
  dfs("",'a');
return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#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)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  vp p;
  rep(i,m) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    p.pb(P(a,b));
  }
  reverse(rng(p));
  vvi es(n);
  vi can(n,1);
  rep(v,n) {
    vi used(n);
    used[v] = 1;
    rep(i,m) {
      int a = p[i].fi, b = p[i].se;
      if (used[a] && used[b]) {
        can[v] = 0;
        break;
      }
      if (used[a]) {
        used[b] = 1;
        es[v].pb(i);
      }
      if (used[b]) {
        used[a] = 1;
        es[v].pb(i);
      }
    }
  }
  int ans = 0;
  rep(v,n)rep(u,v) {
    if (!can[v]) continue;
    if (!can[u]) continue;
    vi used(n);
    used[v] = used[u] = 1;
    int now = 1;
    vi ne = es[v];
    ne.insert(ne.end(),rng(es[u]));
    sort(rng(ne)); uni(ne);
    for (int ei : ne) {
      int a = p[ei].fi, b = p[ei].se;
      if (used[a] && used[b]) {
        now = 0;
        break;
      }
      if (used[a]) {
        used[b] = 1;
      }
      if (used[b]) {
        used[a] = 1;
      }
    }
    ans += now;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


typedef vector<ll> vec;
typedef vector<vector<ll> > mat;

int m;

const ll mod = 1e9 + 7;

vec matmul(vec &dp, mat &mt) {
    vec ret(m, 0);
    for (int i = 0; i < m; ++i) for (int j = 0; j < m; ++j) {
        (ret[i] += mt[i][j] * dp[j]) %= mod;
    }
    return ret;
}

mat update(mat &mt) {
    mat ret(m, vec(m, 0));
    for (int i = 0; i < m; ++i) for (int j = 0; j < m; ++j)
        for (int k = 0; k < m; ++k) {
        (ret[i][j] += mt[i][k] * mt[k][j]) %= mod;
    }
    return ret;
}

void matpow(vec &dp, mat &mt, ll k) {
    m = (int)dp.size();
    while (k) {
        if (k & 1) dp = matmul(dp, mt);
        mt = update(mt);
        k /= 2;
    }
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    
    vec dp(n, 1);
    mat mt(n, vec(n));
    
    rep(i, n) rep(j, n) cin >> mt[i][j];
    
    matpow(dp, mt, k);
    // cout << sz(dp) << endl;
    // cout << endl; rep(i, n) cout << dp[i] << " "; cout << endl;
    // cout << endl; rep(i, n) { rep(j, n) cout << mt[i][j] << " "; cout << endl; }
    ll ans = 0;
    rep(i, n) (ans += dp[i]) %= mod;
    cout << ans << endl;
}


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

int main(){
  ll n,m;cin >> n >> m;
  atcoder::dsu d(n);
  ll ans = n - 1;
  
  rep(i,m){
   ll a,b;cin >> a >> b;
    --a;--b;
    if( !d.same(a,b) ){
      d.merge(a,b);
      --ans;
    }
  }
  cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 3760
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=2e5+100;
int a[MAXN],b[MAXN];
int main(){
	ios;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	reverse(b+1,b+1+n);
	int l=INF,r=-1,c;
	for(int i=1;i<=n;i++){
		if(a[i]==b[i]){
			c=a[i];
			l=min(l,i);
			r=max(r,i);
		}
	}
	for(int i=1;i<=n;i++){
		if(l>r) break;
		if(l<=r && b[i]!=c && a[i]!=c){
			swap(b[i],b[l]);
			l++;
		}
	}
	if(l>r){
		cout<<"Yes"<<'\n';
		for(int i=1;i<=n;i++){
			if(i!=n) cout<<b[i]<<' ';
			else cout<<b[i]<<'\n';
		}
	}
	else cout<<"No"<<'\n';
	return 0;
}

Measured memory_bytes: 5204
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] T = new long[N];
		for(int i = 0 ; i < N ; i++) {
			T[i] = sc.nextLong();
		}
		long ans = T[0];
		for(int i = 1 ; i < N ; i++) {
			ans = lrd(ans, T[i]);
		}
		System.out.println(ans);
	}

	public static long gcd(long a, long b) {
		long v1;
		while(b != 0) {
			v1 = a % b;
			a = b;
			b = v1;
		}
		return a;
	}

	public static long lrd(long a, long b) {
		return a / gcd(a, b) * b;
	}
}


Measured memory_bytes: 21844
// problem: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_B
// require: graph/bellman_ford.d

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long INF = 1L << 50;

void main() {
    auto s = readln.split.map!(to!int);
    auto n = s[0];
    auto m = s[1];
    auto start = s[2];
    auto g = new Edge!long[][](n);
    foreach (_; 0..m) {
        s = readln.split.map!(to!int);
        auto u = s[0];
        auto v = s[1];
        long c = s[2];
        g[u] ~= Edge!long(v, c);
    }

    auto dist = bellman_ford!(long, INF)(g, start);

    if (dist.map!(d => d == -INF).any) {
        writeln("NEGATIVE CYCLE");
    } else {
        dist.map!(d => d == INF ? "INF" : to!string(d)).each!writeln;
    }
}
struct Edge(T) {
    int to;
    T cost;
}

T[] bellman_ford(T, T inf)(const Edge!(T)[][] graph, int start) {
    int n = graph.length.to!int;
    auto dist = new T[](n);
    dist[] = inf;
    dist[start] = 0;

    foreach (i; 0..n) {
        foreach (u; 0..n) {
            foreach (e; graph[u]) {
                if (dist[u] != inf && dist[e.to] > dist[u] + e.cost) {
                    dist[e.to] = dist[u] + e.cost;
                    if (i == n - 1) {
                        dist[e.to] = -inf;
                    }
                }
            }
        }
    }

    auto stack = new int[](n);
    int sp = 0;

    foreach (i; 0..n) {
        if (dist[i] == -inf) {
            stack[sp++] = i;
        }
    }

    while (sp > 0) {
        int u = stack[--sp];
        foreach (e; graph[u]) {
            if (dist[e.to] == -inf) continue;
            dist[e.to] = -inf;
            stack[sp++] = e.to;
        }
    }

    return dist;
}



Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >>k;
  int a;
  vector<int> vec;
  REP(i,n){
      cin >> a;
      vec.push_back(a);
  }
  SORT(vec);
  REV(vec);
  int ans = 0;
  REP(i,k){
      ans+=vec[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = set()
B = set()

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        A.add(b)
    elif b == N:
        B.add(a)

if A & B:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


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

a = n - 2 if n > 2 else 0
b = m - 2 if m > 2 else 0
counter =  a * b

if counter == 0:
    if n == 1 and m == 1:
        counter = 1
    elif n == 1:
        counter = m - 2
    else:
        counter = n - 2

print(counter)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  int counter = 0;
  for (int i = 0; i < s.size(); i++)
  {
  	if (s[i] == '1') counter++;
  }
  
  cout << counter <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if (x < r){
    cout << "No" << endl;
  } else if (y < r){
    cout << "No" << endl;
  } else if (x + r > W){
    cout << "No" << endl;
  } else if (y + r > H){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3116
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int main(){
    double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
    while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2){
        if( xa1 > xb2 || ya1 > yb2 || xa2 < xb1 || ya2 < yb1){
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
    return 0;
}

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

int ans[1005][1005];
int main(){
  int R, C, A, B;
  cin >> R >> C >> A >> B;
  for(int i=1; i<=B; i++){
    for(int j=A+1; j<=C; j++)
      ans[i][j] = 1;
  }

  for(int i=B+1; i<=R; i++){
    for(int j=1; j<=A; j++){
      ans[i][j] = 1;
    }
  }

  for(int i=1; i<=R; i++){
    for(int j=1; j<=C; j++){
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 7536
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
    string s;
    cin >> s;
    puts(s.substr(0,4) == "YAKI" ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>


using namespace std;

double five_hundred[7]={35.50, 37.50, 40.0, 43.0, 50.0, 55.0, 70.0};
double thousand[7]={71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0};
string test_class[7]={"AAA", "AA", "A", "B", "C", "D", "E"};
int main(){
    double a,b;
    while(cin>>a>>b){
        for(int i=0; i<=7; i++){
            if(i==7){
                cout<<"NA"<<endl;
                break;
            }else if(five_hundred[i]>a&&thousand[i]>b){
                cout<<test_class[i]<<endl;
                break;
            }
        }
    }
    
}

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


void solve(long long N, long long K){
    if(K > 1) cout << (N-K) << endl;
    else cout << 0 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
W,H,x,y = map(int,input().split())

ans = 0
if W % 2 == 0 and W//2==x and H %2 == 0 and H//2==y:
    ans = 1

tate = min((W-x)*H , (x - 0)*H)
yoko = min((H-y)*W , (y - 0)*W)
k = max(tate,yoko)

if (x == W and y == 0) or (x == 0 and y == H) or (x == W and y == H) or (x == 0 and y == 0):
    k = (W*H)/2

if H == W:
    if x == y:
        k = (W*H)/2
    elif y + x == H:
        k = (W*H)/2



k = (W*H)/2
print(k,ans,sep=" ")


Measured memory_bytes: 38384
package main

import (
	"fmt"
)

func main() {

	cards := map[string][]bool{}

	for i := 0; i < 13; i++ {
		for _, v := range []string{"S", "H", "C", "D"} {
			cards[v] = append(cards[v], false)
		}
	}

	var a int

	fmt.Scan(&a)

	for i := 0; i < a; i++ {
		var b string
		fmt.Scan(&b)

		var c int
		fmt.Scan(&c)

		cards[b][c-1] = true
	}

	for _, v := range []string{"S", "H", "C", "D"} {
		for k2, v2 := range cards[v] {

			if v2 == false {
				fmt.Println(v, k2+1)
			}
		}
	}

}



Measured memory_bytes: 1136
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int a, b; cin >> a >> b;
  int x = b - a;
  int ans = 0;
  for(int i = 1; i <= x - 1; i++){
    ans += i;
  }
  cout << ans - a << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	string s;
	cin >> s;
	if(s.length() < 6)
	{
		cout << "No";
	}
	else
	{
		if(s[2] == s[3] && s[4] == s[5])
		{
			cout << "Yes";
		}
		else
		{
			cout << "No";
		}
		
	}
	


    return 0;
}

Measured memory_bytes: 256
// ABC057B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int N, M;
	cin >> N >> M;
	int a[N], b[N];
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	int c[M], d[M];
	for (int i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
	}
	for (int i = 0; i < N; i++) {
		int index = 0;
		int tempMin = abs(c[0] - a[i]) + abs(d[0] - b[i]);
		for (int j = 1; j < M; j++) {
			if (tempMin > (abs(c[j] - a[i]) + abs(d[j] - b[i]))) {
				tempMin = abs(c[j] - a[i]) + abs(d[j] - b[i]);
				index = j;
			}
		}
		cout << index + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    int N; cin >> N;
    vector<int> P(N);
    vector<int> a(N,-INF);
    int ma;
    cin >> P[0];
    ma = P[0];
    a[0] = P[0];
    for(int i=1;i<N;i++){
        cin >> P[i];
        if(ma>P[i]){
            a[i]=P[i];
            ma = P[i];
        }else{
            a[i]=ma;
        }
    }
    int cnt=0;
    for(int i=0;i<N;i++){
        if(a[i]>=P[i]) cnt++;
        //cerr << a[i] << " " << P[i] << " " << cnt << endl;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt =0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1
                break
            elif 500 * i + 100 * j + 50 * k > x:
                break
print(cnt)

Measured memory_bytes: 9180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;

    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        if ((i % 3 == 0) || (i % 5) == 0)
        {
        }
        else
        {
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define nyan "(=^･ω･^=)"
using namespace std;

const int mod = 1e9 + 7;
const long long INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//using ll = long long;
//using P = pair<int,int>;

int main(){
    int q;
    cin >> q;
    
    rep(i, q){
        string x, y;
        cin >> x >> y;
        
        int n = x.size();
        int m = y.size();
        
        // dp[i][j] : sのi番目, tのj番目までに対する 
        // longest common subsequenceの長さ
        vector<vector<int> > dp(n+1, vector<int>(m+1));
        
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                
                if (x[i] == y[j]) dp[i+1][j+1] = dp[i][j] + 1;
                else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
        
        cout << dp[n][m] << endl;
    }
}


Measured memory_bytes: 6872
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  map<ll,ll> mp;
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  for(auto p:mp){
    ll v=p.first,c=p.second;
    if(v>c){
      ans += c;
    }else{
      ans += c-v;
    }
  }
  cout << ans << endl;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  intll n , a , b ;
  cin >> n >> a >> b ;
  intll key = n/(a+b);
  
  cout << key*a + min( a ,n%(a+b));
}


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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define mod 1e9 + 7
const ll maxN = 1e5+5;
const ll INF = 0x3f3f3f3f;

ll weight[105], value[105], totSum;

int main() {
	Omar45
    int N, W; cin >> N >> W;
    for (int i=0; i<N; i++) {
        cin >> weight[i] >> value[i];
        totSum += value[i];
    }

    ll dp[totSum+3];
    memset(dp, INF, sizeof(dp));
    dp[0] = 0;

    for (int item=0; item<N; item++) {
        for (int tmpVal=totSum-value[item]; tmpVal>=0; tmpVal--){
            dp[tmpVal+value[item]] = min(dp[tmpVal+value[item]], dp[tmpVal]+weight[item]);
        }
    }
    ll res = 0;
	for(int i=0; i<=totSum; i++)
		if(dp[i] <= W)
            res = max(res, (ll)i);
	cout << res;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  vector<int> x(5);
  for (int i = 0; i < x.size(); i++)
  {
    cin >> x[i];
    if (x[i] == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }
  
}

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

const ll MAX = 2000000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 順列計算
long long PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
}

int main(){
  ll N,M;
  cin >> N >> M;
  COMinit();

  // A = 1,2,3,..,N に固定して考える
  // B の組み合わせ数は何も条件がないなら PER(M, N)
  // 少なくとも i 個の A と B が一致している場合は、PER(M-i, N-i)
  // i 個の一致がある場合の組み合わせは COM(M, i)
  // 包徐原理で i 奇数は引く、偶数は足す
  //  i=0 の場合は、全条件不定なので全事象の数になるので ＋ 
  //  i=1 の場合を上記全事象から引くので  ー
  // 固定していた A の組み合わせ数は PER(M ,N)
  ll ans = 0;
  for( ll i=0; i<=N; i++ ) {
    ll c = PER(M-i, N-i);
    c = c * COM(N, i) % MOD;
    if ( i&1 == 1 ) c = -c;
    ans = (ans + c) % MOD;
    if ( ans < 0 ) ans += MOD;
//    cout << i << " : " << ans << endl;
  }
  ans = ans * PER(M,N) % MOD;
  if (ans < 0) ans += MOD;
  cout << ans << endl;
}


Measured memory_bytes: 50456
#include<iostream>

using namespace std;

const int MAX = 1001;

int d[MAX][MAX];
char data[MAX][MAX];
int in;

int solve(){
  for(int i = 1; i <= in; i++){
    for(int j = 1; j <= in; j++){
      if(data[i][j] == '.') d[i][j] = min(d[i-1][j], min(d[i][j-1],d[i-1][j-1]))+1;
    }
  }
  int out = -1;
  for(int i = 1; i <= in; i++)
    for(int j = 1; j <= in; j++)
      if(out < d[i][j]) out = d[i][j];
  return out;
}

int main(){
  while(cin >> in && in){
    for(int i = 1; i <= in; i++){
      for(int j = 1; j <= in; j++){
	cin >> data[i][j];
	if(data[i][j] == '*') d[i][j] = 0;
	else d[i][j] = 1;
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, K = MI()
    pair = ((N * (N - 1)) // 2)
    ans = []
    cnt = 0
    frag = False
    if ((N - 1) * (N - 2))//2 < K:
        print(-1)
        exit()
    else:
        for i in range(1, N):
            start = 0
            ans.append((start, i))
            cnt = (i * (i - 1)) // 2
    if cnt == K:
        print(len(ans))
        for (s, t) in ans:
            print(s+1, t+1)
    if cnt != K:
        for i in range(1, N):
            for j in range(i+1, N):
                ans.append((i, j))
                cnt -= 1
                if cnt == K:
                    print(len(ans))
                    for (s, t) in ans:
                        print(s+1, t+1)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 43316
def main():
    n,m = [int(x) for x in input().split()]

    l_max = 1
    r_min = n
    for i in range(m):
        l,r = map(int, input().split())
        l_max = max(l_max, l)
        r_min = min(r_min, r)

    if r_min-l_max+1 < 0:
        print(0)
    else:
        print(r_min-l_max+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
from collections import defaultdict, deque

n, a, s, h = int(input()), [], [], []
for i in range(n): a.append(int(input())); s.append(list(list(map(int, input().split())) for _ in range(a[i])))
for i in range(2 ** n):
    flag = False
    for j in range(n):
        if (i >> j) & 1:
            for ps in s[j]:
                if (i >> (ps[0]-1) & 1) != ps[1]: flag = True; break
    if not flag: h.append(bin(i)[2:].count('1'))
print(max(h))

Measured memory_bytes: 75472
#include<stdio.h>

int f(int n,int k)
{
  if(n == 1)
    return 0;
  return (f(n-1,k)+k)%n;
}

int main()
{
  while(1)
    {
      int n,k;
      scanf("%d %d",&n,&k);
      if(n+k == 0)
	break;
      printf("%d\n",f(n,k)+1);
    }
}

Measured memory_bytes: 1056
#include <bits/stdc++.h> 
using namespace std;
long long  n,cont,cnt,ans;
int main(){
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
			if(a[i]<0)
			cnt++;}
			if(cnt%2==1){
			for(int i=0;i<n;i++){
				if(b[i]<0)
				b[i]*=(-1);}
				sort(b,b+n);
				int cont=b[0];
				for(int i=0;i<n;i++){
					if(b[i]==cont)
					continue;
					else 
					ans+=b[i];}
					ans-=cont;
					cout<<ans;}
					else {
						for(int i=0;i<n;i++){
							if(a[i]<0){
							a[i]*=(-1);}
							ans+=a[i];}
							cout<<ans;
				}
			}

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

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define PI 3.14159265
#define take(a,n) for(int i=0;i<(n);i++) cin>>(a)[i]
#define out(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int (i)=0;i<(n);(i)++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
using namespace std;


ll poww(ll a,ll b)
{
  ll ans=1;
  for(int i=1;i<=b;i++)
  {
    ans*=a;
  }
  return ans;
}


int max(int a,int b,int c)
{
  if(a>=b && a>=c) return a;
  if(b>=a && b>=c) return b;
  return c;
}

void dfs(int x, int parent, ll *p, vi *v, int *visited)
{
  if(parent!=-1 && !visited[x])
  {
    p[x]+=p[parent];
    visited[x]++;
  }
    for(auto y: v[x])
      if(!visited[y]) dfs(y,x,p,v,visited);
}


int main()
{
  int n,q;
  cin>>n>>q;
  vi v[n];
  int visited[n]={0};
  forup(i,n-1)
  {
    int a,b;
    cin>>a>>b;
    v[a-1].pb(b-1);
    v[b-1].pb(a-1);
  }
  ll p[n]={0};
  forup(i,q)
  {
    int a,b;
    cin>>a>>b;
    p[a-1]+=b;
  }
  /*
  queue<int> tree;
  tree.push(0);
  while(!tree.empty())
  {
      int a=tree.front();
      tree.pop();
      for(auto x:v[a])
      {
        p[x]+=p[a];
        tree.push(x);
      }
  }
*/
visited[0]=1;
dfs(0,-1,p,v,visited);
  for(auto x: p) cout<<x<<" ";

  re 0;

}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    vector<vector<ll>>x(n,vector<ll>());
    vector<vector<ll>>y(n,vector<ll>());
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        for (int j = 0; j < a[i]; ++j) {
            ll c,d;cin >>c>>d;
            c--;
            x[i].push_back(c);
            y[i].push_back(d);
        }
    }
    ll ans=0;
    for (int i = 0; i < (1 << n); ++i) {
        bool flg=true;
        for (int j = 0; j < n; ++j) {
            if(i>>j&1){
                for (int k = 0; k < a[j]; ++k) {
                    if(i>>x[j][k]&1){
//                        if(i==3) {
//                            cout << i << " " << x[j][k] << " " << y[j][k] << endl;
//                        }
                        if(y[j][k]==0)flg=false;
                    }
                    else{
//                        if(i==3) {
//                            cout << i << " " << x[j][k] << " " << y[j][k] << endl;
//                        }
                        if(y[j][k]==1)flg=false;
                    }
                }
            }
        }
        if(flg){
            ll now=__builtin_popcount(i);
            ans=max(ans,now);
        }
    }
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  D
//
//  Created by 曾憲揚 on 2020/9/7.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

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

const int N = 1e5+5;
typedef pair<int, bool> pib;
bool color[N];
vector<pib> e[N];

#define fr first
#define sc second

void dfs(int p, int cur){
    for(auto pa: e[cur]){
        if(pa.fr!=p){
            color[pa.fr]=color[cur]^pa.sc;
            dfs(cur, pa.fr);
        }
    }
}

int main(int argc, const char * argv[]) {
    int n; cin>>n;
    for(int i=1; i<n; i++){
        int u, v, w;
        cin>>u>>v>>w;
        e[u].push_back({v, w%2});
        e[v].push_back({u, w%2});
    }
    
    color[1]=0;
    dfs(0, 1);
    for(int i=1; i<=n; i++)
        cout<<color[i]<<endl;
    return 0;
}


Measured memory_bytes: 11864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  ull a, b;
  cin >> a >> b;

  if (b * 2 >= a) {
    cout << 0 << endl;
  } else {
    cout << a - (b * 2) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())

a=[]
a.append(["#" for i in range(2+w)])
for i in range(h):
    a.append(["#"]+list(input())+["#"])
a.append(["#" for i in range(2+w)])

for i in range(h+2):
    for j in range(w+2):
        print(a[i][j],end="")
    print()

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

vector<vector<int> > tree;
vector<int> treecolor;
int red = 1;
int blue = 0;

void paint(int s, int color){
    for(int i = 0; i < tree[s].size(); i++){
        int to = tree[s][i];
        if(treecolor[to] != 0){
            continue;
        }else{
            if(color == 1){
                red++;
            }else{
                blue++;
            }
            treecolor[to] = color;
            paint(to, color * -1);
        }
    }
}

int main(){
    int n; cin >> n;
    tree = vector<vector<int> >(n+1);
    treecolor = vector<int>(n+1, 0);
    vector<int> anslis(n+1);
    treecolor[1] = 1;
    for(int i = 0; i < n-1; i++){
        int a, b; cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    paint(1, -1);
    int maxred = (n + 2) / 3;
    int maxblue = (n + 1) / 3;
    int maxc = n / 3;
    int rc = 0, bc = 0, c = 0;
    if(red > n / 3 && blue > n/3){
        int i = 1;
        for(;rc < maxred && i <= n; i++){
            if(treecolor[i] == 1){
                anslis[i] = rc * 3 + 1;
                rc++;
            }
        }
        for(; i <= n; i++){
            if(treecolor[i] == 1){
                anslis[i] = c * 3 + 3;
                c++;
            }
        }
        i = 1;
        for(;bc < maxblue && i <= n; i++){
            if(treecolor[i] == -1){
                anslis[i] = bc * 3 + 2;
                bc++;
            }
        }
        for(; i <= n; i++){
            if(treecolor[i] == -1){
                anslis[i] = c * 3 + 3;
                c++;
            }
        }
    }else if(red <= n/3){
        int i = 1;
        for(;i <= n; i++){
            if(treecolor[i] == 1){
                anslis[i] = c * 3 + 3;
                c++;
            }
        }
        i = 1;
        for(; rc < maxred && i <= n; i++){
            if(treecolor[i] == -1){
                anslis[i] = rc * 3 + 1;
                rc++;
            }
        }
        for(; bc < maxblue && i <= n; i++){
            if(treecolor[i] == -1){
                anslis[i] = bc * 3 + 2;
                bc++;
            }
        }
        for(; c < maxc && i <= n; i++){
            if(treecolor[i] == -1){
                anslis[i] = c * 3 + 3;
                c++;
            }
        }
    }else{
        int i = 1;
        for(;i <= n; i++){
            if(treecolor[i] == -1){
                anslis[i] = c * 3 + 3;
                c++;
            }
        }
        i = 1;
        for(; rc < maxred && i <= n; i++){
            if(treecolor[i] == 1){
                anslis[i] = rc * 3 + 1;
                rc++;
            }
        }
        for(; bc < maxblue && i <= n; i++){
            if(treecolor[i] == 1){
                anslis[i] = bc * 3 + 2;
                bc++;
            }
        }
        for(; c < maxc && i <= n; i++){
            if(treecolor[i] == 1){
                anslis[i] = c * 3 + 3;
                c++;
            }
        }
    }
    for(int  i = 1; i <= n; i++){
        cout << anslis[i] << " ";
    }
}

Measured memory_bytes: 17920
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

N,W = MAP()
weight=[]
value=[]
for i in range(N):
    w,v = MAP()
    weight.append(w)
    value.append(v)
MAX_V = 100100

dp = [[MOD]*(MAX_V+1) for _ in range(N+1)]
dp[0][0]=0

for i in range(N):
    for sum_v in range(MAX_V):
        if sum_v - value[i]>=0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v-value[i]]+weight[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v])


for sum_v in range(MAX_V):
    if dp[N][sum_v]<=W:
        res=sum_v
print(res)

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

const long long MAX = 1e18;

int main() {
    int N;
    cin >> N;
    long long *A = new long long[N];
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    
        if (A[i] == 0) {
            cout << 0;
            return 0;
        }
    }
    
    long long sum = 1;
    long long sum_old = 1;
    for (int i = 0; i < N; i++) {
        if (MAX / sum >= A[i]) {
            sum *= A[i];
        } else {
            cout << -1;
            return 0;
        }
    }
    
    cout << sum;
    return 0;
}

Measured memory_bytes: 4408
let x1, y1, x2, y2, x, y = Scanf.scanf " %d %d %d %d" @@ fun a b c d -> a, b, c, d, c - a, d - b
let _ = Printf.printf "%d %d %d %d\n" (x2 - y) (y2 + x) (x1 - y) (y1 + x)

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

vector<char> T(200000);
int maxPD = 0;
int len;

int main () {
  string TT;
  cin >> TT;
  len = TT.size();
  for (int i = 0; i < len; i++) {
    T.at(i) = TT.at(i);
    if(TT.at(i) == '?') {
      if(i > 1 && TT.at(i-1) == 'P') T.at(i) = 'D';
      if(i > 1 && TT.at(i-1) == 'D') T.at(i) = 'D';
      T.at(i) = 'D';
    }
  }
  
  for (int i = 0; i < len; i++) {
    cout << T.at(i);
  }
  
  cout << endl;
  
}

Measured memory_bytes: 3800
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)

int main(void)
{
	string test;
	cin >> test;
	if (test[0] == 'Y'&&test[1] == 'A'&&test[2] == 'K'&&test[3] == 'I') {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = int(input())
    a = 0

    while True:
        a += 1
        for b in range(a):
            if a ** 5 + b ** 5 == x:
                print(a, -b)
                sys.exit()
            if a ** 5 - b ** 5 == x:
                print(a, b)
                sys.exit()


if __name__ == '__main__':
    main()


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

#define LL long long
#define pii pair<LL, LL>
#define mp make_pair

const int maxN = 2e5 + 10;

int n, T, cnt, r;
LL f[maxN + 1][33], sum[maxN + 1];

pii num[maxN + 1];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline bool comp(pii a, pii b)
{
	return b.first * (a.second + 1) < a.first * (b.second + 1);
}

int main()
{
	n = read(), T = read();
	for(int i = 1; i <= n; i++)
	{
		int x = read(), y = read();
		if(!x) sum[++ r] = y;
		else num[++ cnt] = mp(x, y);
	}

	sort(num + 1, num + cnt + 1, comp);
	sort(sum + 1, sum + r + 1);

	for(int i = 1; i <= r; i++) sum[i] += sum[i - 1] + 1;

	for(int i = 0; i <= cnt; i++)
		for(int j = 0; j <= 31; j++) f[i][j] = T + 10;

	f[0][0] = 0;
	for(int i = 1; i <= cnt; i++)
		for(int j = 0; j <= 31; j++)
		{
			f[i][j] = f[i - 1][j];
			if(j) f[i][j] = min(f[i][j], f[i - 1][j - 1] + 1 + num[i].first * (f[i - 1][j - 1] + 1) + num[i].second);
		}
	
	int ans = 0;
	for(int j = 0; j <= 31; j++)
		if(f[cnt][j] <= T) 
			ans = max(ans, (int)(j + upper_bound(sum + 1, sum + r + 1, T - f[cnt][j]) - sum - 1));

	printf("%d", ans);
	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

constexpr ll INF = TEN(18);
const int MX = 3010;

ll dp[MX][MX][4];
ll v[MX][MX];

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    rep(i, K) {
        int r, c, val;
        cin >> r >> c >> val;
        --r, --c;
        v[r][c] = val;
    }

    //rep(i, MX) rep(j, MX) rep(k, 4) dp[i][j][k] = -INF;
    dp[0][0][0] = 0;

    rep(i, R) {
        rep(j, C) {
            for (int k = 2; k >= 0; --k) {
              
                    chmax(dp[i][j][k + 1], dp[i][j][k] + v[i][j]);
                
            }
            rep(k, 4) {
                
                   
                        chmax(dp[i + 1][j][0], dp[i][j][k]);
                    
                    
                        chmax(dp[i][j + 1][k], dp[i][j][k]);
                    
                
            }
        }
    }

    ll ans = -INF;
    rep(k, 4) chmax(ans, dp[R - 1][C - 1][k]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 356280
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

public class Main {

	public static void main(String[] arg) {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s=ob.next();
		int k=0;
		for (int i=0; i<=s.length()-3; i++) {
			if (s.charAt(i)=='A'&&s.charAt(i+1)=='B'&&s.charAt(i+2)=='C') {
				k++;
			}
		}
		System.out.println(k);
	}
}


Measured memory_bytes: 27088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repd(i,n) for(ll i = (n); i >= 0; i--)
#define FOR(i,t,n) for(ll i = (t); i < (n); i++)
#define FORD(i,t,n) for(ll i = (n); i >= t; i--)
#define ALL(x) x.begin(),x.end()
#define asort(x) sort(ALL(x))

int main() {
    int res = 0;
    int N, D;
    double X, Y;
    cin >> N >> D;
    rep(i,N) {
        cin >> X >> Y;
        if((double)sqrt(X*X+Y*Y) <= (double)D) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3840