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

const int INF = 1e9;

int main() {
  int n, t, a;
  cin>>n>>t>>a;
  int h[n];
  double min_diff = 1e6;
  int ans = -1;
  for (int i=0; i<n; i++) {
    int h;
    cin>>h;
    double ti = t - 0.006 * h;
    if (abs(ti - a) < min_diff) {
      min_diff = abs(ti - a);
      ans = i + 1;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

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

  vector<int> c( n );
  for ( int i = 0; i < n; i++ ) c[i] = 0;

  for ( int i = 0; i < m; i++ ) {
    int a, b;
    cin >> a >> b;
    c[a - 1]++;
    c[b - 1]++;
  }

  for ( int i = 0; i < n; i++ ) {
    cout << c[i] << endl;
  }

  return 0;
}


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

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int a, b;
    cin >> a >> b;

    int ans = 0, curr = 1;

    while(curr < b)
    {
        curr = curr - 1 + a;
        ans++;
    }

    cout << ans << "\n";
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rad(n) (((n)/360.)*2*M_PI)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  long double a,b,h,m; cin >> a >> b >> h >> m;
  long double s = (60*h+m)*0.5;
  long double l = 6*m;
  if(l < s)swap(l,s);
  cout << setprecision(30) << sqrt(a*a+b*b-2*a*b*cos(rad(l-s))) << endl;
  return 0;
}


Measured memory_bytes: 4168
#include<bits/stdc++.h>
using namespace std;
void fast(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
}
class data{
	public:
	int point , cost;
	data(int point , int cost){
		this->point = point , this->cost = cost;
	}
	data(){
		
	}
};
vector<vector<int>>dp;
int find_it(int i , vector<data> & all , int &n , int h){
	if(h <= 0){
		return 0;
	}
	if(i == n){
		return INT_MAX;
	}
	if(dp[i][h] != -1){
		return dp[i][h];
	}
	int first = find_it(i + 1 , all , n , h);
	
	int second = find_it(i , all , n , h - all[i].point);
	if(second != INT_MAX){
				second += all[i].cost;
	}
	
	return dp[i][h] = min(first , second);
}
int main(){
	fast();	
	int h, n;
	cin >> h >> n;
	vector<data>all(n);
	for(int i = 0; i < n; ++i){
		cin >> all[i].point >> all[i].cost;
	}
	dp = vector<vector<int>>(n , vector<int>(h + 1 , -1));
	cout << find_it(0 , all , n , h) << "\n";
}


Measured memory_bytes: 40448
#include <stdio.h>
 
int main() {
  int a, b,c,d;
 
  scanf("%d %d %d" , &a,&b, &c);
  
 if(a > b) {
    d = a;
      a = b;
      b = d;
  } if(b > c) {
    d = c;
    c = b;
    b = d;
 
  } if(a > b) {
    d = a;
    a = b;
    b = d;
  }
  printf("%d %d %d\n",a ,b ,c);
 
 
 
  return 0;
}


Measured memory_bytes: 1832
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
void dfs(vector< vector<ll> >&v,vector<bool>&visited,vector<ll>&lazy,ll src,ll prev)
{
    visited[src]=true;
    lazy[src]+=prev;
    for(ll i=0;i<v[src].size();i++)
    {
        if(visited[v[src][i]]==false)
        {
            dfs(v,visited,lazy,v[src][i],lazy[src]);
        }
    }
}
int main()
{
fast;
ll n,q;
cin>>n>>q;
vector< vector<ll> >v(n+1);
for(ll i=0;i<n-1;i++)
{
    ll a,b;
    cin>>a>>b;
    v[a].pb(b);
    v[b].pb(a);
}
vector<ll>lazy(n+1,0);
vector<bool>visited(n+1,false);
for(ll i=0;i<q;i++)
{
    ll a,b;
    cin>>a>>b;
    lazy[a]+=b;
}
dfs(v,visited,lazy,1,0);
for(ll i=1;i<=n;i++)
{
    cout<<lazy[i]<<" ";
}


return 0;
}


Measured memory_bytes: 30592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
const long long int maxn = 1e6;
int A[maxn];
int vis[maxn] = { 0 };
int main()
{
	int N;
	while( scanf("%d",&N) != EOF  ){
		long long int Max = -1;
		int seq = 0;
		for( int i = 0 ; i < N ; i++ ){
			scanf("%d",&A[i]);
			if( A[i] > 1e5 )
				seq += 1;
			else{
				vis[A[i]]++;
				if( A[i] > Max )	Max = A[i];
			}
		}
		int sum = 0;
		for( int i = 0 ; i <= Max ; i++ ){
			if( vis[i] > i )
				sum = sum + ( vis[i] - i );
			if( vis[i] < i && vis[i] != 0 )
				sum = sum + vis[i];
		}
		sum = sum + seq;
		printf("%d\n",sum);
		memset( A , 0 , sizeof(A) );
		memset( vis , 0 , sizeof(vis) );
	}
}

Measured memory_bytes: 7936
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    m = [a//400 for a in A if a < 3200]

    mi = len(set(m))
    ma = len(set(m)) + (N - len(m))
    print(max(1, mi), ma)    


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))

cnt = [0]*(10**5+5)
for i in a:
    cnt[i] += 1

ans = 0
for i in range(1, 10**5+3):
    ans = max(ans, sum(cnt[i-1:i+2]))
print(ans)


Measured memory_bytes: 20844
n,m,c=map(int,input().split())
b=map(int,input().split())
b=[int(i) for i in b]
kazu=0
for i in range(0,n):
    goukei = 0
    a=map(int,input().split())
    a=[int(i) for i in a]
    for j in range(0,m):
        goukei+=a[j]*b[j]
    if goukei+c>0:
        kazu += 1
print(kazu)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int sec()
{
	int h, m, s;
	scanf("%d:%d:%d", &h, &m, &s);
	m += h * 60;
	return s + m * 60;
}
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		vector<pint> t;
		while (n--)
		{
			t.push_back(pint(sec(), 1));
			t.push_back(pint(sec(), -1));
		}
		t.push_back(pint(1 << 25, 0));
		sort(all(t));

		int res = 0;
		int s = 0, p = -1;
		foreach (it, t)
		{
			if (it->first != p)
				max_swap(res, s);
			s += it->second;
			p = it->first;
		}

		printf("%d\n", res);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}


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

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

#define fr first
#define sc second
#define rep(i,x) for(int i = 0 ; i < x ; i ++)

const ll INF = 1000000000000000000;

template <int N = 100010>
struct Tree{
	int n;
	vector<int> G[N];
	int a[N],b[N];
	void in(){
		scanf("%d",&n);
		for(int i = 0 ; i < n-1 ; i ++){
			scanf("%d%d",&a[i],&b[i]);
			G[a[i]].push_back(b[i]);
			G[b[i]].push_back(a[i]);
		}
	}
	
	string s;
	bool alive[N];
	void dfs1(int v,int p){
		alive[v] = false;
		for(int u: G[v]){
			if(u == p)continue;
			dfs1(u,v);
			alive[v] |= alive[u];
		}
		if(s[v-1] == 'W')alive[v] = true;
	}
	
	ll c[N];
	ll len = 0;
	void solve1(){
		for(int i = 1 ; i <= n ; i ++){
			if(!alive[i])continue;
			ll cnt = 0;
			for(int j: G[i]){
				if(alive[j])cnt ++;
			}
			len += cnt;
			if(s[i-1] == 'W')cnt ++;
			if(cnt&1){
				c[i] = 2;
				len ++;
			}
			else c[i] = 0;
		}
	}
	
	ll ret = 0;
	ll dp[N][2];
	void dfs2(int v,int p){
		if(!alive[v]){
			dp[v][0] = dp[v][1] = -INF;
			return;
		}
		dp[v][0] = c[v];
		dp[v][1] = 0;
		for(int u: G[v]){
			if(u == p)continue;
			dfs2(u,v);
			ret = max( ret , dp[v][0]+dp[u][1] );
			ret = max( ret , dp[v][1]+dp[u][0] );
			dp[v][0] = max( dp[v][0] , dp[u][0]+c[v] );
			dp[v][1] = max( dp[v][1] , dp[u][1]+c[v] );
		}
	}
};

int main(){
	Tree<> tree;
	tree.in();
	cin >> tree.s;
	
	int root = -1;
	for(int i = 0 ; i < tree.n ; i ++){
		if(tree.s[i] == 'W'){
			root = i+1;
			break;
		}
	}
	if(root == -1){
		puts("0");
		return 0;
	}
	
	tree.dfs1(root,0);
	tree.solve1();
	tree.dfs2(root,0);
	cout << tree.len-tree.ret << endl;
}



Measured memory_bytes: 14848
#include<bits/stdc++.h>
#define endl '\n'
#define INF ((1 << 31) - 1)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 1000000007;
using namespace std;
ll dpt[105][100005];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int W;
  int w[105], v[105];
  

  cin >> n >> W;
  for(int i = 0;i < n;i++){
    cin >> w[i] >> v[i];
  }
  
  dpt[0][0] = 0;
  for(int i = 0;i < n;i++){
    for(int j = 0;j <= W;j++){
      if(j >= w[i]){
       	dpt[i + 1][j] = max(dpt[i][j - w[i]] + v[i], dpt[i][j]);
      }else{
	dpt[i + 1][j] = dpt[i][j];
      }
    }
  }

  cout << dpt[n][W] << endl;
  return 0;
}


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

using namespace std;

#define EPS (1e-7)
#define INF (1e9)


typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rep2(i, n) for(int i = 1; i <= (n); i++)
#define all(a) begin(a),end(a)
#define endl '\n'




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


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
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;
   }
}

inline void init(vector<int>& uf) {

    iota(all(uf), 0);
}

inline int root(vector<int>& uf, int x) {

    if(uf[x] == x) {

        return x;
    }
    else {

        return uf[x] = root(uf, uf[x]);
    }
}

inline bool same(vector<int>& uf, int x, int y) {

    return root(uf, x) == root(uf, y);
}

inline void unite(vector<int>& uf, int x, int y) {

    x = root(uf, x);
    y = root(uf, y);

    if(x == y) return;

    uf[x] = y;
}

int N, M;

void Input() {

    cin >> N >> M;

}



void Solve() {


    vi p(N);

    vi uf(N+1);
    init(uf);

    for(int i = 0; i < N; i++) {

        cin >> p[i];
    }

    for(int i = 0; i < M; i++) {

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

        unite(uf, x, y);
    }

    int res = 0;
    for(int i = 0; i < N; i++) {

        if(same(uf, i+1, p[i])) res++;
    }

    cout << res << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 1024
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next()
  var ans = ""
  for (c <- s.toList) {
    if (c == 'B') {
      ans = ans.slice(0, ans.length-1)
    } else {
      ans += c
    }
  }
  println(ans)
}


Measured memory_bytes: 55260
def bookCount(bookCountN)
    shimo1 = bookCountN.digits[0]
    hon = [2,4,5,7,9]
    pon = [0,1,6,8]
    
    if hon.include?(shimo1)
    	yomikata = "hon"
    elsif pon.include?(shimo1)
    	yomikata = "pon"
    else
    	yomikata = "bon"
    end
    
    puts yomikata   
end

bookCount(gets().to_i)

Measured memory_bytes: 14136
dic = {}

N = int(input())
for i in range(N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
M = int(input())
for i in range(M):
  t = input()
  if t in dic:
    dic[t] -= 1
  else:
    dic[t] = -1

sort_dic = sorted(dic.items(), key = lambda x:x[1], reverse = True)
print(sort_dic[0][1] if sort_dic[0][1] > 0 else 0)


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll k, a, b;

	cin >> k >> a >> b;

	ll ans = 0;
	ll reachA = a - 1;

	if (b - a >= 3 && k >= reachA)
	{
		ll t = k - reachA;
		ans = a;

		if (t >= 2)
		{
			ans += (b - a) * (t/2LL);
			t -= (t / 2LL) * 2LL;
		}

		if (t >= 1)
		{
			ans++;
		}
	}
	else
	{
		ans = 1 + k;
	}

	cout << ans << endl;


	return 0;
}


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

typedef long long ll;

int t[100000];
int k[500007];

int main(){
  ll n,m;
  ll p;
  int sp = 0;
  int a,i;
  ll ans = 1;
  int limit;

  scanf("%lld %lld", &n, &p);

  for(i = 0;i <= 500000;i++) k[i] = 0;

  if(n == 1){
    printf("%lld\n", p);
    return 0;
  }

  if(p == 1){
    printf("%lld\n", p);
    return 0;
  }

  limit = sqrt(p);

  for(i = 2;i <= limit;i++){
    while(p % i == 0){
      k[i]++;
      p = p/i;
    }
  }

  for(i = 2;i <= 500000;i++){
    ans = ans*pow(i,(k[i])/n);
  }

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

  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
typedef complex<double> cd;
static const double pi = 3.141592653589793;

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

  int n,m; cin >> n >> m;
  vector<int> cnt(n, 0);
  rep(i, m) {
    int a,b; cin >> a >> b;
    --a, --b;
    ++cnt[a];
    ++cnt[b];
  }

  rep(i, n) {
    if(cnt[i] % 2 == 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 640
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }

    bool ok = true;
    for (auto x: mp) {
        if (x.se % 2) ok = false;
    }
    
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

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

int main() {
    string str;
    cin >> str;
    set<char> alphabet;
    rep(i, str.length()) alphabet.insert(str.at(i));
    if(alphabet.size() == 26) {
        cout << "None" << endl;
    } else {
        char ans = 'z';
        rep(i, 26) if(alphabet.find(i + 'a') == alphabet.end()) {
            ans = i + 'a';
            break;
        }
        cout << ans << endl;
    }
}

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

struct Coodi{
	int x;
	int y;
};

int jumpPoint[][2] = {
	{ -1, -2 }, { 0, -2 }, { 1, -2 },
	{ 2, -1 }, { 2, 0 }, { 2, 1 },
	{ 1, 2 }, { 0, 2 }, { -1, 2 },
	{ -2, 1 }, { -2, 0 }, { -2, -1 },
};

bool jumpFrog( Coodi* frog, Coodi* spPos, int spQua, int spNumber )
{
	if( spNumber != -1 ){
		if( frog->x < spPos[ spNumber ].x - 1 || frog->x > spPos[ spNumber ].x + 1
			|| frog->y < spPos[ spNumber ].y - 1 || frog->y > spPos[ spNumber ].y + 1 ){
			return false;
		}
		if( spNumber == spQua - 1 ){
			return true;
		}
	}

	for( int i = 0; i < 12; ++i ){
		Coodi jumpedPos;
		jumpedPos.x = frog->x + jumpPoint[ i ][ 0 ];
		jumpedPos.y = frog->y + jumpPoint[ i ][ 1 ];
		if( jumpedPos.x < 0 || jumpedPos.x > 9
			|| jumpedPos.y < 0 || jumpedPos.y > 9 ){
			continue;
		}
		if( jumpFrog( &jumpedPos, spPos, spQua, spNumber + 1 ) ){
			return true;
		}
	}

	return false;
}

int main()
{
	Coodi frogPosition;

	while( cin >> frogPosition.x >> frogPosition.y ){
		if( frogPosition.x == 0 && frogPosition.y == 0 ){
			break;
		}

		int spQuantity;
		cin >> spQuantity;
		Coodi* spPosition = new Coodi[ spQuantity ];
		for( int i = 0; i < spQuantity; ++i ){
			cin >> spPosition[ i ].x >> spPosition[ i ].y;
		}

		if( jumpFrog( &frogPosition, spPosition, spQuantity, -1 ) ){
			cout << "OK" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1180
input()
p = [int(x) for x in input().split()]
q = sorted(p)
d = [(pi, qi) for pi, qi in zip(p, q) if pi != qi]
print("YES" if len(d) == 0 or len(d) == 2 and d[0][0] == d[1][1] and d[1][0] == d[0][1] else "NO")

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N, M;
  cin >> N >> M;
  ll total = 0;
  ll a;
  REP(i, M) {
    cin >> a;
    total += a;
  }

  if (total > N) {
    cout << "-1" << endl;
  } else {
    cout << N - total << endl;
  }

  return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll d,g;
    cin >> d >> g;
    ll p[d],c[d];
    for(i=0;i<d;i++){
        cin >> p[i] >> c[i];
    }
    ll ret = INF;
    for(i=0;i<1<<d;i++){
        ll top=INF,prob_cnt=0,point=0;
        for(j=d-1;j>=0;j--){
            if(i>>j & 1){
                prob_cnt += p[j];
                point += p[j]*(j+1)*100 + c[j];
            }else {
                if(top == INF)top = j;
            }
        }
        if(point >= g){
            ret = min(ret,prob_cnt);
        }else {
            point = g-point; // 残りの得点
            if(point<=(p[top]-1)*100*(top+1)){
                prob_cnt += (point-1+((top + 1) * 100)) / ((top + 1) * 100);
                ret = min(ret,prob_cnt);
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
short int d[5000][5000];
int main(){
  int n,m,p[5000],l[5000],i,j,k[5000]={0};
  int nk[5000],q[5000],t,r,rr,nn,min,mi;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d %d",&p[i],&l[i]);
  while(m--){
    scanf("%d %d",&i,&j);
    i--;
    j--;
    d[i][k[i]++]=j;
    d[j][k[j]++]=i;
  }
  for(i=0;i<n;i++){
    int f[5000]={0};
    f[i]=1;
    for(r=t=0;r<k[i];r++)f[q[r]=d[i][r]]=1;
    nk[i]=k[i];
    for(j=1;j<l[i];j++){
      for(rr=r;rr-t;t++){
	for(m=0;m<k[q[t]];m++){
	  nn=d[q[t]][m];
	  if(f[nn]==1)continue;
	  q[r++]=nn;
	  f[nn]=1;
	  d[i][nk[i]++]=nn;
	}
      }
    }
  }
  /*for(i=0;i<n;i++){
    for(j=0;j<nk[i];j++)printf("%d ",d[i][j]+1);printf("\n");
    }//*/
  int f[5000]={0};
  int c[5000]={0};
  for(i=mi=0;i<n;i++){
    f[mi]=1;
    for(j=0;j<nk[mi];j++){
      nn=d[mi][j];
      if(f[nn])continue;
      if(c[nn]==0||c[nn]>c[mi]+p[mi])c[nn]=c[mi]+p[mi];
    }
    min=2100000000;
    for(j=0;j<n;j++){//printf("%d ",c[j]);
      if(f[j]||c[j]==0)continue;
      if(min>c[j])min=c[mi=j];
    }//printf("\n");
  }
  printf("%d\n",c[n-1]);
  return 0;
}

Measured memory_bytes: 48712
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
    while(1){
      ll H,W;
      cin >> H >> W;
      if(H == 0 && W == 0) break;
      rep(i,0,H){
        rep(j,0,W){
          cout << "#";
        }
        cout << "\n";
      }
      cout << "\n";
    }


  return 0;
}





Measured memory_bytes: 3092
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	long N;

	cin >> N;

	long long A[N];

	for(long i =0; i < N;i++){
		cin >> A[i];
	}

	sort(A, A+N);

	long long ans1 = 0, ans2 = 0;

	long long tmp1, tmp2;

	tmp2 = A[0];
	tmp1 = A[0];
	ans1 += abs(tmp1-tmp2);
	for(long i = 1; i < N; i++){
		long long x; 
		if(i % 4 == 3 || i % 4 == 0){
			x = A[i/2];
			ans1 += abs(tmp2 - x);
		} else {
			x = A[N-1 - i/2];
			ans1 += abs(x - tmp2);
		}
		tmp2 = tmp1;
		tmp1 = x;
	}

	tmp2 = A[N-1];
	tmp1 = A[N-1];
	ans2 += abs(tmp1-tmp2);
	for(long i = 1; i < N; i++){
		long long x;
		if(i % 4 == 1 || i % 4 == 2){
			x = A[i/2];
			ans2 += abs(tmp2 - x);
		} else {
			x = A[N-1 - (i/2)];
			ans2 += abs(x - tmp2);
		}
		tmp2 = tmp1;
		tmp1 = x;
	}

	ans1 = max(ans1, ans2);

	cout << ans1 << endl;

	return 0;
}


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

namespace solver{
  void solve(){
    int N; std::cin >> N;
    std::vector<int64_t> L(N);
    for(int i = 0; i < N; ++i) std::cin >> L[i];

    int ans = 0;

    for(int i = 0; i < N; ++i){
      for(int j = i + 1; j < N; ++j){
        for(int k = j + 1; k < N; ++k){
          int x = L[i], y = L[j], z = L[k];

          if(x != y and y != z and z != x){
            if(x + y > z and y + z > x and z + x > y){
              ++ans;
            }
          }
        }
      }
    }

    std::cout << ans << "\n";
  }
}

int main(){
  solver::solve();
  return 0;
}


Measured memory_bytes: 3580
n=int(input())
w=list(map(int,input().split()))

ans = 100 * 100

s1 = w[0]
s2 = sum(w) - s1
t = abs(s1-s2)

for i in range(1,n-1):
    s1 += w[i]
    s2 -= w[i]
    t = abs(s1-s2)
    if ans > t:
        ans = t

print(ans)

Measured memory_bytes: 3064
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  ll n;cin>>n;
  ll sum=0LL;
  for(ll i=1LL;i<=n;i++){
    if(i%3!=0 && i%5!=0)sum += i;
  }
  cout<<sum<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3604
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())

x,y=0,0
for i,j in zip(a,b):
  if i>j:x+=i-j
  else:y+=(j-i)//2
print('Yes' if y >= x else 'No')

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

struct unionFind {
    int elements = 0;
    vector<int> Par, Rank_p;
    unionFind(int n) : Par(n), Rank_p(n) {
        for (int id = 0; id < n; id++) {
            elements   = n;
            Par[id]    = id;
            Rank_p[id] = 0;
        }
    }
    int find(int x) {
        if (Par[x] == x)
            return x;
        else
            return Par[x] = find(Par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (Rank_p[x] < Rank_p[y])
            Par[x] = y;
        else {
            Par[y] = x;
            if (Rank_p[x] == Rank_p[y]) Rank_p[x]++;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int groups() {
        set<int> se;
        for (auto x : Par) {
            se.insert(x);
        }
        return se.size();
    }
};

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

    lint ans = 0;
    for (lint b = k + 1; b <= n; b++) {
        lint p = n / b;
        lint r = n % b;
        ans += p * max(0ll, b - k) + max(0ll, r - k + 1);
        dd(p, r);
        dd(b, ans);
        if (k == 0) { ans--; }
    }

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

Measured memory_bytes: 4704
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        long N = sc.nextInt();
        long K = sc.nextInt();
        for (long f = K; f <= N; f++) {
            long min = (f)*(f-1)/2;;
            long max = (N+1)*(N)/2 - (N+1-f)*(N-f)/2;
            ans += max-min+1;
            ans%=MOD;
            
            // System.out.println(min);
            // System.out.println(max);
        }
        System.out.println(ans+1);
    }

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


Measured memory_bytes: 35636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N, M;
	cin >> N >> M;

	int A[M+1];
	for(int i=0; i<M; i++) {
		int a;
		cin >> a;
		A[i] = a;
		if(i>0 && A[i-1]+1 == A[i]) {
			// 到達不可
			cout << 0;
			return 0;
		}
	}
	A[M] = N+1;

	int aIndex = 0;
	int ans[N+1];
	ans[0] = 1;
	if(A[0] == 1) {
		ans[1] = 0;
		aIndex = 1;
	} else {
		ans[1] = 1;
	}
	for(int i=2; i<=N; i++) {
		if(i == A[aIndex]) {
			ans[i] = 0;
			aIndex++;
		} else {
			ans[i] = (ans[i-2] + ans[i-1])%(1000000007);
		}
	}

	cout << ans[N];

	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//セグメント木
//0-indexed
//#include <vector>
//#include <functional>
template<typename T> struct segment_tree {
	long long n; //vの要素数
	long long m; //葉の数
	std::vector<T> v; //セグ木
	std::function<T(T, T)> op; //二項演算
	T id_e; //単位元

	//コンストラクタ
	segment_tree(std::vector<T> &a, auto f, T b) {
		op = f;
		id_e = b;
		m = 1;
		while (m < a.size()) m *= 2;
		n = 2 * m - 1;
		v.resize(n, id_e);
		for (long long i = 0; i < a.size(); i++) v[m - 1 + i] = a[i];
		for (long long i = m - 2; i >= 0; i--) {
			v[i] = op(v[2 * i + 1], v[2 * i + 2]);
		}
	}

	//1点更新
	void point_update(long long a, T b) {
		a += m - 1;
		v[a] = b;
		while ((a - 1) / 2 != a) {
			a = (a - 1) / 2;
			v[a] = op(v[2 * a + 1], v[2 * a + 2]);
		}
	}

	//遅延なし区間取得の補助関数
	T range_sub(long long a, long long b, long long cur, long long l, long long r) {
		if (a <= l && r <= b) return v[cur];
		if (r < a || b < l) return id_e;
		return op(
			range_sub(a, b, 2 * cur + 1, l, (l + r) / 2),
			range_sub(a, b, 2 * cur + 2, (l + r) / 2 + 1, r)
		);
	}

	//遅延なし区間取得
	T range(long long a, long long b) {return range_sub(a, b, 0, 0, m - 1);}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	const ll p = 998244353;

	ll n;
	cin >> n;
	vector<vll> v(n, vll(3, 0));
	for (ll i = 0; i < n; i++) cin >> v[i][0] >> v[i][1];
	sort(all(v));
	for (ll i = 0; i < n; i++) v[i][2] = i;

	vll dp1(n, 0);
	dp1[n - 1] = n - 1;

	auto f = [&] (ll a, ll b) {return max(a, b);};
	segment_tree<ll> sg(dp1, f, 0);

	for (ll i = n - 2; i >= 0; i--) {
		vll z = {v[i][0] + v[i][1], 0, 0};
		auto itr = lower_bound(all(v), z);
		if (itr == v.end()) dp1[i] = n - 1;
		else if ((*itr)[2] == i + 1) dp1[i] = i;
		else dp1[i] = sg.range(i + 1, (*itr)[2] - 1);
		sg.point_update(i, dp1[i]);
		//cout << dp1[i] << endl;
	}

	vll dp2(n + 1, 1);
	dp2[n - 1] = 2;
	for (ll i = n - 2; i >= 0; i--) {
		dp2[i] = dp2[i + 1];
		dp2[i] += dp2[dp1[i] + 1];
		dp2[i] %= p;
		//cout << dp2[i] << endl;
	}
	cout << dp2[0] << endl;
}


Measured memory_bytes: 18432
package main

import (
	"fmt"
	)

	
func main() {
	var n,s int
	fmt.Scan(&n)
	A:=make([]int,n)
	
	for i:= range A {
		var a int
		fmt.Scan(&a)
		A[i] = a
		s += a
	}
	
	for i:=1;i<len(A);i+=2{
		s -= 2 * A[i]
	}
	ans := []int{}
	ans = append(ans,s)
	
	for i:=1;i<len(A);i++{
		res := 2* A[i-1]-ans[i-1]
		ans = append(ans,res)
	}
	for i, v:=range ans {
		if i == 0{
			fmt.Printf("%d",v)
		} else {
			fmt.Printf(" %d",v)
		}
		
	}
}

Measured memory_bytes: 8320
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

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

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

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

	auto N=in(),M=in(),K=in();
	vll A=vecin(N),B=vecin(M);
	vll SA(N+1,0);
	REP(i,N){
		SA[i+1] = SA[i]+A[i];
	}

	ll S=-1,P=-1;
	REP(i,N+1){
		if(SA[i]>K){
			S = SA[i-1];
			P = i-1;
			break;
		}
	}
	if(S<0){
		S = SA[N];
		P = N;
	}
	ll X=0,T=0;
	while(X<M && S+T+B[X]<=K){
		T+=B[X];
		X++;
	}
	ll maxP=P+X;
	for(int i=P-1;i>=0;i--){
		S = SA[i];
		P = i;

		while(X<M && S+T+B[X]<=K){
			T+=B[X];
			X++;
		}
		maxP = max(maxP,P+X);
	}
	out(maxP);
	return 0;
}


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


int main() {

    int n;
    cin >> n;
    if (1 <= n && n <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}

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

arr = sorted(x)

for i in range(n):
    if x[i] <= arr[(n+1) // 2 - 1]:
        print(arr[(n+1) // 2])
    else:
        print(arr[(n+1) // 2 - 1])

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

const int N = 5005;
const int md = 1e9 + 7;

int n;
vector<int> G[N];
int nchild[N];
int fact[N], C[N][N];
int dp[N], tmp[N];
int ans;

void prepare() {
	fact[0] = 1; for (int i = 1; i < N; ++i) fact[i] = 1LL * fact[i-1] * i % md;
	for (int i = 0; i < N; ++i) C[i][0] = 1;
	for (int i = 1; i < N; ++i) {
		for (int j = 1; j <= i; ++j) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % md;
	}
}

void dfs(int u, int p) {
	nchild[u] = 1;
	for (int v : G[u]) if (v != p) {
		dfs(v, u);
		nchild[u] += nchild[v];
	}
}

int find_centroid(int u, int p) {
	for (int v : G[u]) if (v != p && nchild[v] * 2 >= n) {
		return find_centroid(v, u);
	}
	return u;
}

void add(int &x, int y) {
	x += y; while(x >= md) x -= md; if (x < 0) x += md;
}

int solve(vector<int> &a) {
	int sz = a.size();
	memset(dp, 0, sizeof dp);
	dp[0] = 1;

	int sum = 0;
	for (int i = 0; i < sz; ++i) {
		for (int j = 0; j <= sum + a[i]; ++j) tmp[j] = 0;
		for (int j = 0; j <= sum; ++j) for (int k = 0; k <= a[i]; ++k) {
			int mul = 1LL * C[a[i]][k] * C[a[i]][k] % md;
			add(tmp[j + k], 1LL * dp[j] * (1LL * mul * fact[k] % md) % md);
		}
		sum += a[i];
		for (int j = 0; j <= sum; ++j) dp[j] = tmp[j];
	}

	int ret = 0;
	for (int i = 0; i <= sum; ++i) {
		int cur = 1LL * dp[i] * fact[sum - i] % md;
		if (i & 1) add(ret, -cur);
		else add(ret, cur);
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v); G[v].push_back(u);
	}
	prepare();
	dfs(1, -1);
	int centroid = find_centroid(1, -1);

	if (nchild[centroid] * 2 == n) { 
		// there are two centroids which are connected by an edge
		printf("%d\n", 1LL * fact[n / 2] * fact[n / 2] % md);
		return 0;
	}

	vector<int> vec;
	dfs(centroid, -1);
	for (int v : G[centroid]) {
		vec.push_back(nchild[v]);
	}
	ans += solve(vec);
	vec.push_back(1); // including centroid
	ans += solve(vec);

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

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

using namespace std;

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

    string s, t;
    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    string result = "";

    vector<vector<int>> dp(n + 1, vector<int>(m + 1));

    for (int i = 1; i <= n; i++)
    {
        
        for (int j = 1; j <= m; j++)
        {
            // cout << s[i - 1] << " " << t[j - 1] << endl;
            if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    // cout << "Here" << endl;
    int i = n, j = m;

    while (i > 0 && j > 0)
    {
        // cout << i << " " << j << endl;
        if (dp[i][j] == dp[i - 1][j])
        {
            i--;
        }
        else if (dp[i][j] == dp[i][j - 1])
        {
            j--;
        }
        else
        {
            result += s[i - 1];
            i--;
            j--;
        }
    }

    reverse(result.begin(), result.end());
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 35584
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n, m, p;
vector<pair<int, int>> edge[2501];
long long di[2500];


vector<int> rev[2501];
bool visited[2500];
bool goal[2500];
void ok() {
	queue<int> q;
	q.push(n - 1);
	visited[n - 1] = true;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		goal[u] = true;
		for (int v : rev[u]) {
			if (!visited[v]) {
				visited[v] = true;
				q.push(v);
			}
		}
	}
}


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

	cin >> n >> m >> p;
	rep(i,m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		edge[a].emplace_back(b, c - p);
		rev[b].emplace_back(a);
	}
	rep(i, n)di[i] = -(1LL << 60);
	di[0] = 0;

	ok();


	bool update;
	rep(i, 2 * n) {
		update = false;

		rep(u, n) {
			if (!goal[u] || di[u] == -(1LL << 60))continue;
			for (auto p : edge[u]) {
				int v, d;
				tie(v, d) = p;
				if (goal[v] && di[v] < di[u] + d) {
					di[v] = di[u] + d;
					update = true;
				}
			}
		}


		if (!update)break;
	}


	if (update) {
		cout << -1 << endl;
	}
	else {
		cout << max(0ll, di[n - 1]) << endl;
	}



	return 0;
}

Measured memory_bytes: 640
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

hh = inputs[0][0]
ww = inputs[0][1]
r  = inputs[1][0]
c  = inputs[1][1]

# body
if $debugFlag
end

puts (hh - r)*(ww - c)


Measured memory_bytes: 3836
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
	int n, t;

	bool check;

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		check = false;

		if (i % 3 == 0)
		{
			check = true;
		}
		else
		{
			t = i;

			for (int j = 0; j <= 5; j++)
			{
				if (t % 10 == 3)
				{
					check = true;
				}

				t /= 10;
			}
		}

		if (check == true)
		{
			cout << ' ' << i;
		}
	}

	cout << endl;

	return 0;
}

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

int main() {
    cout.precision(3);
    cout << fixed;
    int n;
    cin >> n;
    double x1, y1, x2, y2, x3, y3;
    while (n--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        if (y1 == y2) swap(x1, x3), swap(y1, y3);
        if (y1 == y3) swap(x1, x2), swap(y1, y2);

        // y = a * x + b
        double mx1, my1, a, b;
        mx1 = (x1 + x2) / 2.0;
        my1 = (y1 + y2) / 2.0;
        a = -(x2 - x1) / (y2 - y1);
        b = my1 - a * mx1;

        // y = c * x + d
        double mx2, my2, c, d;
        mx2 = (x1 + x3) / 2.0;
        my2 = (y1 + y3) / 2.0;
        c = -(x3 - x1) / (y3 - y1);
        d = my2 - c * mx2;

        // intersection
        double cx, cy;
        cx = (d - b) / (a - c);
        cy = (a * d - b * c) / (a - c);

        cout << cx << " " << cy << " " << hypot(cx - x1, cy - y1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1300
def gcd(a,b):
  while b:a,b=b,a%b
  return a
n=int(input())
a=list(map(int,input().split()))
if n==2:print(max(a[0],a[1]));exit()
left=[a[0]]
for i in range(1,n):left.append(gcd(left[-1],a[i]))
right=[a[n-1]]
for i in range(n-2,-1,-1):right.append(gcd(right[-1],a[i]))
right.reverse()
ans=max(right[1],left[n-2])
print(max(ans,max(gcd(left[i-1],right[i+1])for i in range(1,n-1))))

Measured memory_bytes: 14400
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int a,b;
	cin>>a>>b;
	int ans=max(0,a-2*b);
	cout<<ans<<endl;
	return 0;
}


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

const int INF = 1e9 + 5;

int main()
{
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    int ans = 0;
    vector<int> value(n, INF);
    value[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j : {i + 1, i + 2})
            {
                if (j < n) {
                    value[j] = min(value[j], value[i] + abs(h[i] - h[j]));
                }
            }
    }
    cout << value[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(int, A, B, C);
	out(max(C-A+B, 0));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

void  bubbleSort(int number[], int length);


int score[100005];

int main() {
	int N,K,Q;
	int A[100005];
	
	scanf("%d%d%d", &N, &K, &Q);

	for (int i = 0; i < Q; i++) {
		scanf("%d", &A[i]);
		score[A[i]-1]++;
	}

	for (int i = 0; i < N; i++) {
		//printf("%d", score[i] + K - Q);
		if (score[i] + K - Q > 0) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}


	}





}

/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 1280
l_n=[]
l_m=[]
ans='No'
n,m=map(int,input().split())
for i in range(n):
	l_n.append(input())
for i in range(m):
	l_m.append(input())
#print(l_n)
#print(l_m)
for k in range(n-(m-1)):
	count=0
	for j in range(n):
		#print(l_n[j][k:k+m])
		if l_n[j][k:k+m] == l_m[count]:
			count+=1
			if count==m:
				ans='Yes'
				break
		else:
			count=0
print(ans)

Measured memory_bytes: 3064