akhauriyash/Code-Regression huggingface dataset:
import functools


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    a = list(map(lambda x: int(x), inputs))

    count = 0
    light = 1
    N = len(a)
    while 1:
        next_light = a[light - 1]
        count += 1
        if next_light == 2:
            return count
        elif count > N:
            return -1
        light = next_light


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)


Measured memory_bytes: 13980
#include <iostream>

using namespace std;

int main(){
    
    int h[10], i;
    
    for(i = 0; i < 10; i++){
        
        cin >> h[i];
        
        if(h[i] < 0 || h[i] > 10000)
            i--;
    }
    
    int a = 0, b = 0, c = 0, temp;
    
    for(i = 0; i < 10; i++){
        
        if(h[i] > c){
            c = h[i];
            if(c > b){
                temp = b;
                b = c;
                c = temp;
                if(b > a){
                    temp = a;
                    a = b;
                    b = temp;
                }
            }
        }
    }
    
    cout << a << "\n" << b << "\n" << c << "\n";
    
    return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
    char s[10];
    scanf("%s", s);
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])printf("Yes\n");
    else if(s[0] == s[2] && s[2] != s[1] && s[1] == s[3])printf("Yes\n");
    else if(s[0] == s[3] && s[3] != s[1] && s[1] == s[2])printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	if n%2 != 0 {
		fmt.Println("No")
		return
	}
	for i := range s[:n/2] {
		if s[i] != s[i+n/2] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    string S;
    cin >> S;
    int N=S.size(),flag=0;
    
    for(int i=0; i<N; i++){
        if(i%2==0){
            if(S.at(i)=='R' || S.at(i)=='U' || S.at(i)=='D'){
                flag=0;
            }
            else{
                flag=1;
                break;
            }
        }
        if(i%2==1){
            if(S.at(i)=='L' || S.at(i)=='U' || S.at(i)=='D'){
                flag=0;
            }
            else{
                flag=1;
                break;
            }

        }

    }
    if(flag==1){
        cout << "No" << endl;
    }
    else{

     cout << "Yes" << endl;
    }
 
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b;
  c = a % 2, d = b % 2;
  if(c * d == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    string s;
    cin >> n >> s;
    
    vector<int> temp(n);
    int cand[4][2] = {{1, 1}, {1, 0}, {0, 1}, {0, 0}};
    for(int i = 0; i < 4; ++i){
        temp[0] = cand[i][0];
        temp[1] = cand[i][1];
        
        for(int j = 1; j < n-1; ++j){
            if(temp[j] == 1){
                if(s[j] == 'o'){
                    temp[j + 1] = temp[j - 1];
                }
                else{
                    temp[j + 1] = temp[j - 1] ^ 1;
                }
            }
            else{
                if(s[j] == 'x'){
                    temp[j + 1] = temp[j - 1];
                }
                else{
                    temp[j + 1] = temp[j - 1] ^ 1;
                }
            }
        }
        
        bool flag = true;
        for(int j = 0; j < n; ++j){
            if(temp[j] == 1){
                if(s[j] == 'o'){
                    if(temp[(j - 1 + n) % n] != temp[(j + 1) % n]){
                        flag = false;
                        break;
                    }
                }
                else{
                    if(temp[(j - 1 + n) % n] == temp[(j + 1) % n]){
                        flag = false;
                        break;
                    }
                }
            }
            else{
                if(s[j] == 'x'){
                    if(temp[(j - 1 + n) % n] != temp[(j + 1) % n]){
                        flag = false;
                        break;
                    }
                }
                else{
                    if(temp[(j - 1 + n) % n] == temp[(j + 1) % n]){
                        flag = false;
                        break;
                    }
                }
            }
        }
        
        if(flag){
            for(int j = 0; j < n; ++j){
                if(temp[j] == 1){
                    cout << "S";
                }
                else{
                    cout << "W";
                }
            }
            cout << "\n";
            return 0;
        }
    }
    
    cout << -1 << endl;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   int n,m;
   cin>>n>>m;
   int a[n][m];
   for(int i=0;i<n;i++)
     for(int j=0;j<m;j++)
       cin>>a[i][j];
   int cnt=0;
   for(int i=1;i<n;i++)
   {
       for(int j=i-1;j>=0;j--)
       {
           double s=0,ans=0;
           for(int k=0;k<m;k++)
           {
               ans=(a[i][k]-a[j][k])*(a[i][k]-a[j][k])+ans;
           }
           s=sqrt(ans);
           int ss=(int) s;
           if(ss==s) cnt++;
       }
   }
    cout<<cnt<<endl;
}


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

using namespace std;

int main()
{
	string S;
	cin >> S;
	if (S.find('A') != string::npos && S.find('B') != string::npos) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int mod = 1e9+7;
const int MX = 1e5+10;
vii dp(MX, vi(13)); // dp[i][j] = i文字目まででできる整数を13で割ったあまりがjであるときの総数

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

  string s;
  cin >> s;
  int n = sz(s);
  if(s[0] == '?') {
    rep(i,10) dp[0][i] = 1;
  }
  else dp[0][s[0]-'0'] = 1;
  REP(i,n) {
    rep(j,13) {
      auto f = [&](int m) {
        int nj = j*10 + m;
        nj %= 13;
        dp[i][nj] += dp[i-1][j];
        dp[i][nj] %= mod;
      };
      if(s[i] == '?') {
        rep(k,10) f(k);
      }
      else f(s[i]-'0');
    }
  }
  cout << dp[n-1][5] << endl;
}

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

string s;
int main(void) {
	cin >> s;
	string d = s.substr(0, 4);
	if(d == "YAKI") printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string s;
  cin >> s;
  
  ll cnt = 0, ans = 0;
  rep(i, s.size()) {
    if(s[i] == 'A') cnt++;
    else if(s[i] == 'T') cnt++;
    else if(s[i] == 'G') cnt++;
    else if(s[i] == 'C') cnt++;
    else cnt=0;
    chmax(ans, cnt);
  }
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 3588
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    K = int(input().strip())
    S = input().strip()
    size = len(S)
    if size <= K:
        return S
    else:
        ans = S[:K] + "." * 3
        return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9168
#include<stdio.h>

int main(void)
{
  int a,b;
  scanf("%d", &a);
  scanf("%d", &b);
  
  if (a > b)
    printf("a > b\n");
  if (a < b)
    printf("a < b\n");
  if (a == b)
    printf("a == b\n");

  return 0;
}

Measured memory_bytes: 1752
fun main(args: Array<String>) {
	val (n, a, b, c) = readLine()!!.split(" ").map { it.toInt() }
	val v = IntArray(n)
	for (i in 0 until n) {
		v[i] = readLine()!!.toInt()
	}

	var answer = Long.MAX_VALUE

	for (i in 0 until (1 shl (n * 2))) {
		var tmp = IntArray(3, { 0 })
		var now = i
		var cost = 0L
		for (j in 0 until n) {
			val currentchecking = now % 4
			now /= 4
			if (currentchecking < 3) {
				if (tmp[currentchecking] != 0) {
					cost += 10
				}
				tmp[currentchecking] += v[j]
			}
		}
		var flag = true
		for (j in 0 until 3) if (tmp[j] == 0) flag = false
		if (flag) {
			answer = Math.min(answer, (cost + Math.abs(a - tmp[0]) + Math.abs(b - tmp[1]) + Math.abs(c - tmp[2]).toLong()))

		}

	}
	println(answer)
}

Measured memory_bytes: 40596
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

std::vector<std::vector<int>> g;
std::vector<long> dp, c;
bool ans = true;
int n;

long dfs(int v, int p = -1){
	if(g[v].size() == 1) return dp[v] = c[v];
	if(~dp[v]) return dp[v];
	
	long S = 0, ma = 0;
	for(auto e : g[v]){
		if(e == p) continue;
		S += dfs(e, v);
		ma = std::max(ma, dfs(e, v));
	}
	
	if(c[v] > S or S > 2 * c[v]) return dp[v] = ans = false;
	if(c[v] < ma) return dp[v] = ans = false; 
	
	return dp[v] = 2 * c[v] - S;
}

int main(){
	cin >> n; dp.resize(n, -1); g.resize(n); c.resize(n);
	for(int i = 0; i < n; i++) cin >> c[i];
	for(int i = 0; i < n - 1; i++){
		int a, b; cin >> a >> b;
		
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	
	if(n == 2){
		if(c[0] == c[1]) cout << "YES" << endl;
		else cout << "NO" << endl;
		return 0;
	}
	
	for(int i = 0; i < n; i++){
		if(g[i].size() == 1) continue;
		
		if(!dfs(i) and ans) cout << "YES" << endl;
		else cout << "NO" << endl;
		break;
	}
	
	return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



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

typedef long long ll;

using namespace std;

int main() {
    int N;
    cin >> N;
    map<ll, ll> hist;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        hist[A]++;
    }
    int Q;
    cin >> Q;
    ll S = 0;
    for (auto h : hist) {
        S += h.first * h.second;
    }
    for (int i = 0; i < Q; i++) {
        int B, C;
        cin >> B >> C;
        S -= B * hist[B];
        S += C * hist[B];
        hist[C] += hist[B];
        hist[B] = 0;
        cout << S << endl;
    }
    return 0;
}



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

using namespace std;
typedef long long ll;

double dist(double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int ways(int n){
    if(n==1) return 1;
    else return n*ways(n-1);
}

int main(){
    cout<<fixed<<setprecision(10);
    int n;
    double distance,sumofdist = 0;
    cin>>n;
    double numofways = ways(n);
    vector<double> x(n),y(n),order(n);
    rep(i,n) cin>>x[i]>>y[i];
    rep(i,n) order[i] = i;
    do{
        distance = 0;
        // rep(i,n) cout<<(int) order[i]<<" ";
        rep(i,n-1){
            distance += dist(x[order[i]],y[order[i]],x[order[i+1]],y[order[i+1]]);
        }
        // cout<<distance<<endl;
        sumofdist += distance/numofways;
    }while(next_permutation(order.begin(),order.end()));
    cout<<sumofdist<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

const int MAX_M=100000,MAX_N=100000,MAX_K=200000;

struct P{
	int x,y;
	int index;
};

bool comp(const P &a,const P &b){
	if (a.y!=b.y){
		return a.y<b.y;
	}
	return a.x<b.x;
}

bool comp2(const P &a,const P &b){
	if (a.x!=b.x){
		return a.x<b.x;
	}
	return a.y<b.y;
}

int M,N,K;
P p[MAX_K+2];

struct edge{
	int to,cost;
};

typedef pair<long long,int> PA;

const long long INF=1000000000000000;

int V;
vector<edge> G[MAX_K*2+4];

long long d[MAX_K*2+4];

long long dijkstra(){
	priority_queue<PA,vector<PA>,greater<PA> > que;
	fill(d,d+V,INF);
	d[K+2]=0;
	que.push(PA(0,K+2));
	while(!que.empty()){
		PA pa=que.top();
		que.pop();
		int v=pa.second,dis=pa.first;
		if (dis>d[v]) continue;
		for (int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if (d[v]+e.cost<d[e.to]){
				d[e.to]=d[v]+e.cost;
				que.push(PA(d[e.to],e.to));
			}
		}
	}
	return min(d[K+1],d[2*K+3]);
}

int main(){
	scanf("%d %d %d",&M,&N,&K);
	for (int i=0;i<K;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		p[i+1].x=x;
		p[i+1].y=y;
		p[i+1].index=i+1;
	}
	p[0].x=1;	//スタート
	p[0].y=1;
	p[0].index=0;
	p[K+1].x=M;	//ゴール
	p[K+1].y=N;
	p[K+1].index=K+1;
	V=K*2+4;	//頂点の個数
	//辺を張る
	sort(p,p+K+2,comp);	//横の辺を張る
	for (int i=0;i<K+1;i++){
		if (p[i].y==p[i+1].y){
			int cost=p[i+1].x-p[i].x;
			edge e{p[i+1].index,cost};
			G[p[i].index].push_back(e);
			e.to=p[i].index;
			G[p[i+1].index].push_back(e);
		}
	}
	sort(p,p+K+2,comp2);	//縦の辺を張る
	for (int i=0;i<K+1;i++){
		if (p[i].x==p[i+1].x){
			int cost=p[i+1].y-p[i].y;
			edge e{p[i+1].index+K+2,cost};
			G[p[i].index+K+2].push_back(e);
			e.to=p[i].index+K+2;
			G[p[i+1].index+K+2].push_back(e);
		}
	}
	for (int i=1;i<=K;i++){
		edge e{i+K+2,1};
		G[i].push_back(e);
		e.to=i;
		G[i+K+2].push_back(e);
	}
	long long res=dijkstra();
	if (res==INF){
		res=-1;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 39988
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	REP(i, n) {
		int t;
		cin >> t;
		if (t >= k) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








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

	vector<int> x(n);
	vector<int> dis(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		dis[i] = abs(start - x[i]);
	}
	
	int ans = dis[0];

	for (int i = 1; i < n; i++) {
		ans = gcd(ans, dis[i]);
	}

	cout << ans << endl;






	return 0;

}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << ", ";
#define ll long long
#define pb push_back
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
const int MOD = 1e9 + 7;
int main()
{
    FAST_IO
    int n,m;
    cin >> n >> m;
    vector<vector<int>> grid(n, vector<int>(m, 0));
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++)
        {
            if (s[j] == '#')
                grid[i][j] = 1;
        }
    }

    vector<vector<int>> dp(n, vector<int>(m, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            // debug(j);
            // cout << "======" << endl;
            if (grid[i][j])
                continue;
            if (i + 1 < n)
            {
                if (!grid[i + 1][j])
                {
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j] %= MOD;
                }
            }
            if (j + 1 < m)
            {
                if (!grid[i][j + 1])
                {
                    dp[i][j + 1] += dp[i][j];
                    dp[i][j + 1] %= MOD;
                }
            }
        }
    }
    cout << dp[n - 1][m - 1] % MOD << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[4];
	int k=0;
	while(n>0)
	{
		a[k]=n%10;
		n/=10;
		k++;
	}
	swap(a[0],a[3]);
	swap(a[1],a[2]);
	for(int i=-1;i<=1;i+=2)
		for(int j=-1;j<=1;j+=2)
			for(int p=-1;p<=1;p+=2)
			{
				int sum=a[0]+i*a[1]+j*a[2]+p*a[3];
				if(sum==7)
				{
					cout<<a[0];
					if(i==-1) cout<<'-'; else cout<<'+';
					cout<<a[1];
					if(j==-1) cout<<'-'; else cout<<'+';
					cout<<a[2];
					if(p==-1) cout<<'-'; else cout<<'+';
					cout<<a[3]<<"=7";
					return 0;
				}
			}
 } 

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int b[n-1];
  	int a[n];
    for(int i = 0;i<n-1;i++) cin >> b[i];
    a[0] = b[0];
  	int sum = a[0];
  	for(int i = 1;i<n-1;i++){
    	a[i] = min(b[i-1],b[i]);
      sum += a[i];
    }
  	a[n-1] = b[n-2];
  	sum += a[n-1];
    cout << sum;
  	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    string s;
    cin >> s;
    string t;
    cin >> t;
    int cnt = 0;
    bool ans_flag = false;
    int s_len = (int)s.length();
    int t_len = (int)t.length();
    for (int i = s_len - t_len; i >= 0; i--)
    {
        cnt = 0;
        for (int j = 0; j < t_len; j++)
        {
            if (s[i + j] == t[j] || s[i + j] == '?')
            {
                cnt++;
            }
            if (cnt == t_len)
            {
                ans_flag = true;
            }
        }
        if (ans_flag == true)
        {
            for (int j = 0; j < t_len; j++)
            {
                s[j + i] = t[j];
            }
            for (int k = 0; k < s_len; k++)
            {
                if (s[k] == '?')
                    s[k] = 'a';
            }
            break;
        }
    }
    if (ans_flag == false)
        cout << "UNRESTORABLE\n";
    else
        cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
def dist(a,b,c,d):
  return ((a-c)**2+(b-d)**2)**(1/2)
N=int(input())
m=0
z=[list(map(int,input().split())) for _ in range(N)]
for i in range(N):
  for j in range(i+1,N):
    m+=dist(z[i][0],z[i][1],z[j][0],z[j][1])
print(float(2*m/N))

Measured memory_bytes: 3064
public class Main {

    /**
     * ????????????????????????
     *
     * @param args
     */
    public static void main(String[] args) {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                System.out.println(i + "x" + j + "=" + i * j);
            }
        }
    }
}

Measured memory_bytes: 24128
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vvi			vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)		for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)	((c).find(x) != (c).end()) 
#define cpresent(c,x)	(find(all(c),x) != (c).end()) 
#define int ll
using namespace std;

#define N  100005

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n;
		cin >> n;

		vector< pii > v;

		rep(i, 0, n)
		{
			int x;
			cin >> x;
			v.pb({x, i});
		}

		vector< pii > a, b;

		rep(i, 0, n)
		{
			a.pb({i+v[i].first, i});
			b.pb({i-v[i].first, i});
		}

		// rep(i, 0, n)
		// cout << a[i].first << " " << a[i].second << endl;


		sort(all(b));

		// cout << endl;
		// rep(i, 0, n)
		// cout << b[i].first << " " << b[i].second << endl; 
		// cout << endl;

		int ans = 0;

		rep(i, 0, n)
		{
			int idx1 = lower_bound(all(b), a[i]) - b.begin();
			int idx2 = lower_bound(all(b), make_pair(a[i].first+1, a[i].second))  - b.begin();
			// cout << idx1 << " " << idx2 << endl;

			ans+=idx2-idx1;
		}

		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 15844
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int k;
	cin >> k;
	if (k==1||k==2||k==3||k==5||k==7||k==11||k==13||k==15||k==17||k==19||k==23||k==29||k==31) {
		cout << 1 << endl;
	}
	else if(k == 4 || k == 6 || k == 9 || k == 10 || k == 14 || k == 21 || k == 22 || k == 25 || k == 26){
		cout << 2 << endl;
	}
	else if (k==8||k==12||k==18||k==20||k==27) {
		cout << 5 << endl;
	}
	else if (k==16) {
		cout << 14 << endl;
	}
	else if (k==24) {
		cout << 15 << endl;
	}
	else if(k==32){
		cout << 51 << endl;
	}
	else {
		cout << 4 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#define INF 100000000
#define dis first
#define v second.first
#define m second.second
using namespace std;
typedef pair <int, pair <int,int> > P;

int N,M,L,K,A,H;
vector <P> mp[101];
int ice[101];

void dijkstra(int start,int goal) {
  int visited[101][101] = {},D[101][101];
  for(int i=0;i<=M;i++)
    for(int j=0;j<=N;j++) D[i][j] = -INF;
  P t;
  t.dis = 0,  t.v = start ,t.m = 0;
  priority_queue <P> Q;
  Q.push(t);
  while(!Q.empty()){
    t = Q.top(),Q.pop();
    if(t.m > M || visited[t.m][t.v] == 1) continue;
    visited[t.m][t.v] = 1;

    if(ice[t.v] == 1) 
      for(int i=t.m-1;i>=0;i--) {
	P nt = t;
	nt.m = i;
	nt.dis = t.dis - (t.m - i);
	if(nt.m <= M && D[nt.m][nt.v]<nt.dis) Q.push(nt) , D[nt.m][nt.v]=nt.dis;
      }

    for(int i=0;i<mp[t.v].size();i++){
      P nt;
      nt.dis = t.dis-mp[t.v][i].dis;
      nt.v = mp[t.v][i].v;
      nt.m = t.m + mp[t.v][i].dis;
      if(nt.m <= M && D[nt.m][nt.v] < nt.dis) Q.push(nt),D[nt.m][nt.v] = nt.dis;
    }
  }
  int ans = -INF;
  for(int i=0;i<=M;i++) ans = max(ans,D[i][goal]);
  
  if(ans == -INF) cout <<"Help!"<<endl;
  else cout << -ans <<endl;
}

int main() {
  while(1){
    cin >> N >> M >> L >> K >> A >> H;
    if(N==0&&M==0&&L==0&&K==0&&A==0&&H==0)break;

    for(int i=0;i<=N;i++) ice[i] = 0,mp[i].clear();
    for(int i=0;i<L;i++) {
      int a;
      cin >> a;
      ice[a] = 1;
    }

    for(int i=0;i<K;i++){
      int x,y,cost;
      cin >> x >> y >> cost;
      P t;
      t.v = y,   t.dis = cost,   t.m=cost;
      mp[x].push_back(t);
      t.v = x,   t.dis = cost,   t.m=cost;
      mp[y].push_back(t);
    }
    dijkstra(A,H);
  }
  return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    int ans = x / 500;
    ans *= 1000;
    x %= 500;
    int tmp = x / 5;
    ans += tmp * 5;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

static const int MAX = 200000;
int main(){
    int itr;
    int R[MAX];
    
    std::cin >> itr;
    //for(int i = 0; i < itr; i++){
    //    std::cin >> R[i];
    //}
    int maxv = -2000000000;
    int minv;
    std::cin >> minv;
    for(int j = 1; j < itr; j++){
        int r;
        std::cin >> r;
        if(maxv < (r - minv)) maxv = r - minv;
        if(minv > r) minv = r;
    }
    std::cout << maxv << std::endl;
    return 0;
    
}


Measured memory_bytes: 3116
#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 chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#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)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll 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); }


ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60


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

    int N, A, B;
    cin >> N >> A >> B;
    
    
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    sort(all(v), greater<ll>());
    
    double ave = 0;
    rep(i, A) ave += v[i];
    out(FIX(7) << ave / A);
    
    int sum_a = 0, sum_n = 0;
    rep(i, A) if (v[i] == v[A - 1]) { sum_a++; sum_n++; }
    rep3(i, A, N) if (v[i] == v[A - 1]) sum_n++;
    
    
    
    if (sum_a == A) {
        // out(sum_n << " " << sum_a);
        ll cnt = 0;
        for (sum_a = A; sum_a <= B; ++sum_a) cnt += nck(sum_n, sum_a);
        // rep3(i, A, sum_n + 1) cnt += nck(sum_n, i);
        out(cnt);
    } else {
        // out(sum_n << " " << sum_a);
        ll cnt = 0;
        cnt = nck(sum_n, sum_a);
        out(cnt);
    }
}




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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, from[1009];
ll A[1009], dp[1009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    ll ma=-1LL<<60;
    int best=-1;
    
    rep1(i,N){
        cin>>A[i];
        dp[i]=A[i];
        for(int x=1;x<i;x++) if((i-x)%2==0){
            if(dp[x]+A[i]>dp[i]){
                from[i]=x;
                dp[i]=dp[x]+A[i];
            }
        }
        if(dp[i]>ma){
            ma=dp[i];
            best=i;
        }
    }
    cout1(ma);
    vector<int> ans;
    int x;
    for(x=N;x>best;x--) ans.push_back(x);
    while(from[x]>0){
        int y=from[x];
        while(y<x){
            ans.push_back((x+y)/2);
            x-=2;
        }
    }
    rep(i,x-1) ans.push_back(1);
    cout1(ans.size());
    for(auto a:ans){
        cout1(a);
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i,j,n,maxv=0,minv=0;

  scanf("%d",&n);
  int R[n];
    for(i=0;i<n;i++)
      {
	scanf("%d",&R[i]);
      }
    maxv = R[1]-R[0];
    minv = R[0];
    for(j=1;j<=n-1;j++)
      {
	if(maxv < R[j]-minv)
	  {
	    maxv = R[j] - minv;
	  }
	if(minv > R[j])
	  {
	    minv = R[j];
	  }
      }
    printf("%d\n",maxv);
    return 0;
}

Measured memory_bytes: 1380
#include <stdio.h>
int main(void){
int hi,koku,suu,kokud,suud,n,m;
n=0;
m=0;
scanf("%d",&hi);
scanf("%d",&koku);
scanf("%d",&suu);
scanf("%d",&kokud);
scanf("%d",&suud);
while(!(koku<=0)){
koku=koku-kokud;
n++;
}
while(!(suu<=0)){
suu=suu-suud;
m++;
}
if(n>=m){
hi=hi-n;
}
else{
hi=hi-m;
}
printf("%d\n",hi);
return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%lld%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")
#define DUMP(a, n) REP(i, n) printf("%lld%c", a[i], i + 1 == n ? '\n' : ' ')

typedef long long ll;

const int N_MAX = 1000;
const ll INF = 1e15;

int N, M;
ll x[N_MAX];
ll y[N_MAX];
ll z[N_MAX];

ll dp[N_MAX + 1];

void solve() {
  ll ans = 0;
  REP(k, 8) {
    int xs = (k & 1) > 0 ? -1 : 1;
    int ys = (k & 2) > 0 ? -1 : 1;
    int zs = (k & 4) > 0 ? -1 : 1;
    // printf("xs: %d, ys:%d, zs: %d\n", xs, ys, zs);
    fill(dp, dp + M + 1, -INF);
    dp[0] = 0;
    REP(i, N) {
      ll w = x[i] * xs + y[i] * ys + z[i] * zs;
      for (int j = M - 1; j >= 0; j--) {
        dp[j + 1] = max(dp[j + 1], dp[j] + w);
      }
    }
    // DUMP(dp, M + 1);
    ans = max(ans, dp[M]);
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, N) scanf("%lld%lld%lld", x + i, y + i, z + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

int cmp1(const void *p,const void *q)//昇順
{
    return *(int *)p - *(int *)q;
}

typedef long long int int64;

int main()
{
    int64 n;
    int64 x,m;
    int64 i=1;
    int64 num=0;
    int roopflag=0;
    int modmap[100010]={0};
    int64 modsum[100010]={0};
    int64 roop,roopnum,rest;
    int64 ans=0;
    scanf("%lld %lld %lld",&n,&x,&m);

    num=x%m;
    modmap[num]=1;
    modsum[1]=num;
    ans+=num;

    while(i<n)
    {
        i++; //今からi回目
        num=(num*num)%m;
        if(roopflag==1)
        {
            ans+=num;
        }
        else if(modmap[num]==0)
        {
            modmap[num]=i;
            modsum[i]=(modsum[i-1]+num);
            ans+=num;
        }
        else //ループ発見
        {
            roop=i-modmap[num];
            roopnum=(n-i+1)/roop;
            //rest=(n-i)%roop;

            ans+=(modsum[i-1]-modsum[i-roop-1])*(roopnum);
            //printf("i:%lld\n",i);
            //printf("roop:%lld roopnum:%lld\n",roop,roopnum);
            num=modsum[i-1]-modsum[i-2];//numはroopの終端
            i+=(roop*roopnum-1);
            roopflag=1;
        }
        //printf("A_%lld = %lld sum=%lld\n",i,num,ans);
    }

    printf("%lld",ans);
}



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

int main(){
	string a;
	cin >> a;
	for(int i=0; i<a.size() ; i++)
		if(i%2)
		{
			if(a[i]=='R')
			{
				cout << "No";
				return 0;
			}
		}
		else
		{
			if(a[i]=='L')
			{
				cout << "No";
				return 0;
			}
		}

				cout << "Yes";

} 

//, , or .i

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
flag = 1
for i in range(n):
	if a[i]%2 == 0:
		if a[i]%3 != 0 and a[i]%5 != 0:
			flag = 0
if flag == 1:
	print('APPROVED')
else:
	print('DENIED')


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if(i == 4){
            cout << " ";
        }
        cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 3580
#include<cstdio>
#include<cmath>
#include<vector>
#include<cstring>
#include<cstdlib>

using namespace std;

#define N 12+1
#define INF (1e8)
#define rep(i,j) for(int i=0;i<(j);i++)

double dp[1<<N][N];
int r[N];

double diff(int a,int b){
	if(a*b)return sqrt((r[a]+r[b])*(r[a]+r[b])-(r[a]-r[b])*(r[a]-r[b]));
	return r[a+b];
}

int main(){
	char s[1024];
	int n,w;
	while(NULL != gets(s)){
		w = atoi(s);
		n = 1;
		char *p = strchr(s,' ');
		while(p != NULL){
			r[n++] = atoi(p+1);
			p = strchr(p+1,' ');
		}
		rep(i,1<<n)fill(dp[i],dp[i]+n,INF);
		dp[(1<<n)-1][0] = 0;
		for(int i=(1<<n)-2;i>=0;i--){
			rep(j,n)rep(k,n)
				if(!((i>>k)&1))
					dp[i][j] = min(dp[i][j], dp[i|(1<<k)][k] + diff(j,k));
		}
		puts(dp[0][0]>w?"NA":"OK");
	}
	return 0;
}

Measured memory_bytes: 1764
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define fr(i,x) for(int i=0;i<x;i++)
#define MAX 10000005
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}

ll a[MAX];
void sieve(){
    for (int i = 1; i < MAX; i++)
    {
        for (int j = i; j <= MAX; j+=i)
        {
            a[j]++;
        }
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    

    ll n,d,x,y,r,cnt = 0,k;
    cin >> n;
    for (ll i = 0; i <= 1000000; i++)
    {
        cnt = ((cnt*10)+7);
        cnt = cnt%n;
        if(!cnt){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    
    
    
    
    
    
}

Measured memory_bytes: 3652
# import sys
import math #sqrt,gcd
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    r = int(input())
    print(2*math.pi*r)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9172
package main

import "fmt"

func main() {
	var S string

	fmt.Scan(&S)

	if len(S) == 4 {
		if S[0] != S[1] && S[1] != S[2] && S[2] != S[3] {
			fmt.Print("Good")
		} else {
			fmt.Print("Bad")
		}
	}

}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        if (a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 23764
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sam = n*800;
        int man = (n/15)*200;
      
      System.out.print(sam-man);
       
       
      
    }
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<stdlib.h>
int main(){
	int w, h, n, x1, y1, x2, y2, kx, ky, cnt = 0;
	scanf("%d%d%d%d%d", &w, &h, &n, &x1, &y1);
	for (int i = 0; i < n - 1; i++){
		scanf("%d%d", &x2, &y2);
		kx = x2 - x1;
		ky = y2 - y1;
		while (kx > 0 && ky > 0){
			cnt++;kx--;ky--;
		}
		while (kx < 0 && ky < 0){
			cnt++; kx++; ky++;
		}
		cnt += abs(kx) + abs(ky);
		x1 = x2;y1 = y2;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<int> a;
    char curr = s[0]; int put = 1;
    if(curr == '0') put = -1;
    rep(i, 1, s.length() - 1){
        if(s[i] == curr) {
            if(s[i] == '0') put--;
            else put++;
        }
        else{
            a.pb(put);
            curr = s[i];
            if(curr == '0') put = -1;
            else put = 1;
        }
    }
    a.pb(put);
    int cnt = 0;
    f(i, sz(a)){
        if(a[i] < 0) cnt++;
    }
    k = min(cnt, k);
    int mx = 0, cans = 0;
    int l = 0, r = 0;
    cnt = 0;
    f(i, sz(a)){
        if(a[i] < 0){
            if(cnt == k) break;
            cnt++;
            cans -= a[r];
            r++;
        }
        else{
            cans += a[r];
            r++;
        }
    }
    mx = cans;
    while(r < sz(a)){
        cans += abs(a[r]);
        if(a[r] < 0) cnt++;
        r++;
        while(cnt > k){
            cans -= abs(a[l]);
            if(a[l] < 0) cnt--;
            l++;
        }
        mx = max(mx, cans);
    }
    cout<<mx;
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

#define N 100004
ll d[N+1];
ll a[N+1];
vector<ll>c[N+1];
void dfs(ll k){
    for(auto x:c[k]){
        d[x]=d[k]+1;
        dfs(x);
    }
}
int main(){fastio
    ll n,k;cin>>n>>k;
    
    rep(i,1,n){
        cin>>a[i];
        if(i!=1)c[a[i]].pb(i);
    }
    ll ans=0;
    if(k==1){
        rep(i,1,n)if(a[i]!=1)ans++;
        cout<<ans<<endl;
        return 0;
    }
    if(a[1]!=1)ans++;
    dfs(1);d[1]=0;
    vector<ll>dep[N];
    rep(i,1,n)dep[d[i]].pb(i);
    l_l dp[n+1];
    for(ll i=N-1;i>=0;i--){
        if(i==0){
            for(auto x:c[1]){
                ans+=dp[x].first;
            }
        }
        for(auto x:dep[i]){
            ll ma=0,sum=0;
            for(auto y:c[x]){
                sum+=dp[y].first;
                if(dp[y].second==k){
                    sum++;
                }else{
                    Max(ma,dp[y].second);
                }
            }
            dp[x]=l_l(sum,ma+1);
        }
    }
    //rep(i,1,n)cout<<dp[i].first<<" "<<dp[i].second<<endl;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int i; cin >> i;
	int a = (i / 100);
	int b = (i % 100);

	bool is_a_month = (1 <= a && a <= 12);
	bool is_b_month = (1 <= b && b <= 12);

	if (is_a_month && is_b_month) {
		cout << "AMBIGUOUS" << endl;
	}
	if (is_a_month && !is_b_month) {
		cout << "MMYY" << endl;
	}
	if (!is_a_month && is_b_month) {
		cout << "YYMM" << endl;
	}
	if (!is_a_month && !is_b_month) {
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
//#define int long long

//交換しても悪化しないがgreedyの証明の基本構造
//大きいほうから、小さいほうから、前から、後ろから

//条件の厳しいほうからとるべし

void solve() {
	int n; cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp;
    rep(i, n) {
        cin >> a[i];
        mp[a[i]] ++;
    }
    int ans = 0;
    sort(all(a)); reverse(all(a));
    rep(i, n) {
        if(mp[a[i]]) {
            mp[a[i]] --;
            
            ll res = 1;
            while(res <= a[i]) {
                res *= 2;
            }

            if(mp[res - a[i]]) {
                mp[res - a[i]] --;
                ans ++;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 26880