akhauriyash/Code-Regression huggingface dataset:
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    random.seed(10)
    while time.time() - start < 1.9:
        idx = random.randint(0,25)
        d = random.randint(0,D-1)
        if c[idx] == 0 or ans[d-1] == idx:
            continue
        tmp = ans[d]
        ans[d] = idx
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]-1]
            last_d[ans[i]-1] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d] = tmp
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9552
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#include<functional>
typedef long long ll;
using namespace std;

int main(){
  int A,B;
  cin >> A >> B ;
  if(B%A==0){
    cout << A + B << endl;
  }else{
    cout << B-A << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
int main(void){
   int x;
   while(1){
   scanf("%d",&x);
   if(x==0) break;
   int a,m=0,n=0,o=0,p=0,q=0,r=0,s=0;
   for(int i=0;i<x;i++){
       scanf("%d",&a);
       if(a<10) m++;
       if(10<=a&&a<20) n++;
       if(20<=a&&a<30) o++;
       if(30<=a&&a<40) p++;
       if(40<=a&&a<50) q++;
       if(50<=a&&a<60) r++;
       if(60<=a) s++;
   }
   printf("%d\n",m);
    printf("%d\n",n);
     printf("%d\n",o);
      printf("%d\n",p);
       printf("%d\n",q);
        printf("%d\n",r);
   printf("%d\n",s);
 
}
 return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char map[505][505];

vector<ll>to[100005];

int main() {
	ll n, m;
	cin >> n >> m;
	ll a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	queue<ll>que;
	vector <ll> dist(n,inf);
	vector<ll> pre(n, -1);
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		ll v = que.front();
		que.pop();
		for (ll id : to[v]) {
			if (dist[id] != inf)continue;
			dist[id] = dist[v] + 1;
			pre[id] = v;
			que.push(id);
		}
	}
	cout << "Yes" << endl;
	ll ans;
	for (int i = 0; i < n; i++) {
		if (i == 0)continue;
		ans = pre[i];
		ans++;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 13604
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9+7;

int N;
vector<pair<int, int>> E[100001];

ll ans[100001];

void dfs(int cu, int pa = -1, int col = 0) {
	set<int> used;
	used.insert(col);
	int c = 1;
	for(auto to: E[cu]) if (to.first != pa) {
		while (used.count(c)) c++;
		ans[to.second] = c;
		dfs(to.first, cu, c);
		c++;
	}
}

int main() {
	ll n; cin >> n;
	rep(i, 0, n - 1) {
		ll a, b; cin >> a >> b;
		a--; b--;
		E[a].push_back({ b,i });
		E[b].push_back({ a,i });
	}

	dfs(0);

	ll maxV = 0;
	rep(i, 0, n) maxV = max(maxV, (ll)E[i].size());
	cout << maxV << endl;
	rep(i, 0, n - 1) cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	
	while(!isdigit(ch)){
	   if(ch=='-')
	      f=-1;
	   ch=getchar();
	}
	
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() 
{
	ios::sync_with_stdio(0);cin.tie(0);
	n=read();m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4224
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

#define INF 0x3f3f3f3f

using namespace std;

typedef long long LL;
typedef pair<int,int>PII;



int main(void) {
	LL n,m;
	cin >> n >> m;
	LL ans = 0,value = m;
	if(m == 1 || n == 1) ans = 1;
	else if(m & 1) {
		value = m / 2 + 1;
		if(n & 1) {
			ans = 1ll * (n / 2 + 1) * value + (n / 2) * (m - value);
		} else {
			ans = 1ll * (n / 2) * value + (n / 2) * (m - value);
		}
	} else {
		ans = 1ll * n * (value / 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
char s[N];
int n;
bool isl[N];
int main() {
	scanf("%d", &n);
	scanf("%s", s+1);
	isl[1] = 1;
	for (int i = 2; i <= 2*n; ++i) {
		if(s[i] != s[i-1]) isl[i] = (isl[i-1]==true);
		else isl[i] = (isl[i-1]!=true);
	} 
	LL ans = 1, a = 0, b = 0;
	for (int i = 1; i <= 2*n; ++i) {
		if(!isl[i]) {
			if(a-b <= 0) {
				ans = 0;
				break;
			}
			ans = (ans * (a-b))%MOD;
			b++;
		}
		else a++;
	}
	if(a != b) ans = 0;
	if(s[1] == 'W' || s[2*n] == 'W') ans = 0;
	for (int i = 1; i <= n; ++i) ans = (ans*i) % MOD;
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
int main(){
  int n,t=100000000;
  cin>>n;
  int a[n];
  r(i,n)cin>>a[i];
  sort(a,a+n);
  long long sum=0;
  r(i,n){
    sum+=a[i];
  }
  if((sum)%10){
      cout<<sum<<endl;
      return 0;
    }
  r(i,n){
    if((sum-a[i])%10){
      cout<<sum-a[i]<<endl;
      return 0;
    }
  }

   cout<<0<<endl;
}

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

int const N = 100000;
vector<pair<int, int> > g[N + 1];
pair<int, int> ed[N];
bool vis[N + 1];
int dp[N + 1];

void kl(int i, int v) { if (ed[i].first != v)swap(ed[i].first, ed[i].second); }
void no() { printf("-1\n"); exit(0); }

void go(int v = 1, int p = 0){
	dp[v] = dp[p] + 1;
	vis[v] = true;
	int e = 0;
	f(i, 0, g[v].size()){
		int u = g[v][i].first;
		if (u == p)continue;
		if (vis[u]){
			if (dp[u] < dp[v])kl(g[v][i].second, v), ++e;
			continue;
		}
		go(u, v);
		if (ed[g[v][i].second].first == v)++e;
	}
	if (e & 1) { f(i, 0, g[v].size())if (g[v][i].first == p) { kl(g[v][i].second, v); break; } }
	else f(i, 0, g[v].size())if (g[v][i].first == p) { kl(g[v][i].second, p); break; }
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	if (m & 1)no();
	f(i, 0, m){
		scanf("%d%d", &ed[i].first, &ed[i].second);
		g[ed[i].first].emplace_back(ed[i].second, i);
		g[ed[i].second].emplace_back(ed[i].first, i);
	}
	go();
	f(i, 0, m)printf("%d %d\n", ed[i].first, ed[i].second);
}

Measured memory_bytes: 17536
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
using namespace std;
const int N=500000;
bool prime[N];
void sieve(){
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int nxt(){int x;cin >> x;return x;}
int32_t main(){
    base
    int a=nxt(),b=nxt();
    int arr[a];
    gena(arr,a,nxt);
    vector<int>adj[a];
    map<pair<int,int>,int>mp;
    map<int,int>m;
    for(int i=0;i<b;i++){
        int x=nxt()-1,y=nxt()-1;
            adj[x].push_back(y);
            adj[y].push_back(x);
    }
    int total=0;
    for(int i=0;i<a;i++){
        int cnt=0,two=0;
        for(auto v:adj[i]){
            if(arr[i]>arr[v])cnt++;
        }
        if(cnt==adj[i].size())total++;
    }
    cout<<total;
    exit
}


Measured memory_bytes: 10284
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
	map<map<int,int>,int> mm;
	int n;cin>>n;
	vector<string> arrmv;
	for(int i=0;i<n;i++){
		string t;cin>>t;
		arrmv.push_back(t);
	}
	for(int i=0;i<n;i++){
		map<int,int> mmtmp;
		for(int j=0;j<(int)arrmv[i].size();j++){
			mmtmp[arrmv[i][j]-'a']++;
		}
		mm[mmtmp]++;
	}
	int sum=0;
	for(auto it:mm){
		sum+=it.second*(it.second-1)/2;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 69364
#include"bits/stdc++.h"
#include<atcoder/math.hpp>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    int T;
    cin >> T;
    rep(_, T) {
        ll N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    Q = [LSS() for _ in range(n)]

    d = set()

    for i, j in Q:
        if i=='insert':
            d.add(j)
        else:
            if j in d:
                print('yes')
            else:
                print('no')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 300744
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int V; /*?????§????????°*/
struct edge { int to, cost; };
typedef std::pair<int, int> PP;
// ???cost??¨????????????????????¢
std::vector<edge> list[20];
int d[20];
void DIJX(int st) {
	for (int i = 0; i<V; i++)d[i] = INF; // std::fill??§????????????
	d[st] = 0; // ?§????
	std::priority_queue<PP, std::vector<PP>, std::greater<PP>> pq;
	pq.push(std::make_pair(d[st], st)); // (cost,????????????)
	while (!pq.empty()) {
		PP p = pq.top();
		pq.pop();
		int i = p.second; // cost???first??????????????????second
		if (d[i]<p.first)continue;
		for (int k = 0; k<list[i].size(); k++) {
			edge e = list[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(std::make_pair(d[e.to], e.to));
		}
	}
}
int main() {
		int m, a, b, c,dd;
		std::cin >> V;
		std::cin >> m;
		char c1, c2, c3;
		for (int i = 0; i<m; i++) {
			std::cin >> a >>c1>> b >>c2>> c>>c3>>dd;	
			list[a-1].push_back(edge { b-1, c });
			list[b-1].push_back(edge{ a-1, dd });
		}
		int s, g, get, lost,ans=0;
		std::cin >> s >>c1>> g >>c2>> get >>c3>> lost;
		ans += get - lost;
		DIJX(s-1);
		ans -= d[g-1];
		DIJX(g-1);
		ans -= d[s - 1];
		std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3160
#include <stdio.h>

int main()
{
  double  a, b;

  scanf("%lf%lf", &a, &b);

  if(a>b)
    printf("GREATER\n");
  else if(a<b)
    printf("LESS\n");
  else
    printf("EQUAL\n");

  return 0;
}

Measured memory_bytes: 128
_n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i).sort
hash = Hash.new(0)
arr.each { |i| hash[i] += 1 }
dup_hash = hash.filter { |_, v| v != 1 }
hash.each do |j, _|
  (j * 2).step(1000001, j) { |k| hash.delete(k) }
end
dup_hash.each do |k, _|
  hash.delete(k)
end
puts hash.count

Measured memory_bytes: 41176
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n,m,x,y=MI()
X=LI()
Y=LI()
X=sorted(X,reverse=True)
Y=sorted(Y)
if X[0]<Y[0] and X[0]<y and Y[0]>x:
    print("No War")
else:
    print("War")

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;



int main()
{
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashSet<String> set = new HashSet<String>();
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      set.add(s);
    }
    System.out.println(set.size());
  }
}


Measured memory_bytes: 78032
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n%10==9 || n/10==9){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 22868
n,k = map(int,input().split())
v = [int(_) for _ in input().split()]
res = 0
for i in range(n+1):
    for j in range(n+1):
        if i+j > 0 and i+j<=min(n,k):
            l = v[0:i] + v[:-j-1:-1]
            l.sort()
            cnt = 0
            for p in range(len(l)):
                if l[p] >= 0 or cnt >= k-i-j:
                    break
                l[p] = 0
                cnt  += 1
            res = max(res,sum(l))
print(res)

Measured memory_bytes: 3064
H,W = map(int,input().split())
A = [list(input().strip()) for _ in range(H)]
x = [0,0]
A[0][0] = "."
while True:
    if x[0]==H-1 and x[1]==W-1:break
    if x[0]<H-1 and A[x[0]+1][x[1]]=="#":
        A[x[0]+1][x[1]]="."
        x = [x[0]+1,x[1]]
    elif x[1]<W-1 and A[x[0]][x[1]+1]=="#":
        A[x[0]][x[1]+1]="."
        x = [x[0],x[1]+1]
    elif (x[0]<H-1 and A[x[0]+1][x[1]]==".") and (x[1]<W-1 and A[x[0]][x[1]+1]=="."):
        break
    elif (x[0]==H-1 and x[1]<W-1 and A[x[0]][x[1]+1]==".") or (x[1]==W-1 and x[0]<H-1 and A[x[0]+1][x[1]]=="."):
        break
flag = 0
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            flag = 1
            break
    if flag==1:break
if flag==0:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 62312
#include <iostream>
#include "math.h"
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b, x;
    int c, d;
    int m;
    string s;
    
    m = 0;
    
    //round up
//    cin>> a>>b;
//    x = a+b;
//    if (x<0){
//        x*=-1;
//    }
//    if (x%2==0){
//        x =x/2;
//    }
//    else{
//        x = x/2+1;
//    }
//    cout << x;
    
    //sea battle
//    x = 0;
//    cin>> a>>b; //w1, h1
//    cin>> c>>d; //w2, h2
//    //find perimiter
//    //add number of corners
//
//    //find perimeter
//    m = m+ a + (2*b) + c + (2*d);
//    //add the difference between the 2 widths
//    x = a-c;
//    m+=x;
//
//    //add number of corners;
//    m+=4;
//    cout << m;
    
    //back to unlock
//    string password = "";
//    bool unlock = false;
//    cin>> password;
//    cin>> a;
//    string enemyWord[a];
//    for (int i = 0; i< a; i++){
//        cin>> enemyWord[i];
//    }
//        //check if there is a direct word that contain paasword
//    for (int i = 0; i < a; i++){
//        if (enemyWord[i] == password){
//            unlock = true;
//        }
//    }
//        //if end and start of word
//    for (int i = 0; i<a; i++ ){
//        if (enemyWord[i][1] == password[0]){
//            for (int j = 0; j< a; j++){
//                if (enemyWord[j][0] == password[1]){
//                    unlock = true;
//                }
//            }
//        }
//    }
//    if (unlock){
//        cout<< "YES";
//    }
//    else {
//        cout << "NO";
//    }
    //good distance
    m = 0;
    cin>> a;
    cin>> b;
    int points[a][b];
    for (int i = 0; i< a; i++){
        for (int j = 0; j< b; j++){
            cin>> points[i][j];
        }
    }
    for (int i = 0; i< a; i++){
        for (int j = i+1; j< a; j++){ //comparison of  points
            if (i==j){
                continue;
            }
            //find distance as a double
            double distance = 0;
            for (int h = 0; h< b; h++){
                distance+=(points[i][h] - points[j][h]) * (points[i][h] - points[j][h]);
            }
            // square root it
            distance = sqrt(distance);

            //see if it is integer;
            x = 0;
            x = (int)(distance);
            if (distance - x == 0){
                m++;
            }

        }
    }
    cout << m;

    
    
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
class Main{
	public static void main(String[] args) throws IOException {
		int i;
		int[] n = new int[5];
		String[] str = new String[5];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i]=Integer.parseInt(str[i]);
			}
			if(n[0]==0 && n[1]==0) break;
			System.out.println((n[0]>n[1]?n[1]:n[0])+" "+(n[0]>n[1]?n[0]:n[1]));
		}
	}
}

Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
//typedef  long double lld;
typedef pair<int,int> pii;
#define M 200005
lli a[M];
int main()
{
    double d,t,s;
    cin>>d>>t>>s;
    double s1=(d*1.0)/t;
    if(s1>s)
    {
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}


Measured memory_bytes: 3720
'use strict'

const main = (input) => {
    input = input.split('\n').map(i => parseInt(i))
    if(input[0] === 1){
        console.log('Hello World')
    }else{
        console.log(input[1] + input[2])
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

int main()
{
	int N, M; cin >> N >> M;
	vector<int>Count(N);
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		Count[--a]++;
		Count[--b]++;
	}

	bool flag = true;
	for (int i = 0; i < N; i++) {
		if (Count[i] % 2)flag = false;
	}

	cout << (flag ? "YES" : "NO") << endl;

    return 0;
}



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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


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

  int ma = 0;
  int ans = 0;
  rep (i, n) {
    if (ma <= h[i]) {
      ans++;
      ma = h[i];
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n, t, a;
int h[1005];
double amin = 1e9;

int main()
{
	IOS;
	cin >> n >> t >> a;
	int ind;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		double cel = abs((t - h[i] * 0.006) - a);
		if (amin > cel) {
			amin = cel;
			ind = i;
		}
	}
	cout << ind + 1 << endl;
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
# import copy
from collections import deque
# import heapq
# import numpy as np
# import scipy
# import numba
# import sklearn
sys.setrecursionlimit(1000000000)
# MOD = 10 ** 9 + 7


def main():
    n, m, k = map(int, input().split())
    A = deque(map(int, input().split()))
    B = deque(map(int, input().split()))

    cnt_a = 0
    time = 0
    readed_a = deque([])

    for a in A:
        if time + a > k:
            break
        cnt_a += 1
        time += a
        readed_a.append(a)

    readed_b = deque([])
    cnt_ab = cnt_a
    maxcnt_b = cnt_ab
    for b in B:
        while True:
            if time + b <= k:       # 読める
                readed_b.append(b)
                cnt_ab += 1
                if maxcnt_b < cnt_ab:
                    maxcnt_b = cnt_ab
                time += b
                break
            else:                   # 読めない
                if len(readed_a) > 0:   # Aを戻せる
                    cnt_ab -= 1
                    time -= readed_a.pop()
                else:                   # Aがもう無い
                    print(max(cnt_a, maxcnt_b))
                    return
    print(max(cnt_a, maxcnt_b))


if __name__ == "__main__":
    main()


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

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

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i < 10) {
			ans++;
		}
		else if (99 < i && i < 1000) {
			ans++;
		}
		else if (9999 < i && i < 100000) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(2147483647)

n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n - 1):
  a, b = map(int, input().split())
  edges[a - 1].append(b - 1)
  edges[b - 1].append(a - 1)


vertice = [-1 for _ in range(n)]
stack = [(0, 0)]

while stack:
    parent, vertex = stack.pop()
    vertice[vertex] = vertice[parent] * (-1)
    for next in edges[vertex]:
        if next != parent:
            stack.append((vertex, next))

# vertice = [0 for _ in range(n)]
#
#
# def dfs(v, color_i):
#     vertice[v] = color_i
#     for i in edges[v]:
#         if vertice[i] == 0:
#             dfs(i, color_i*(-1))
#
# dfs(0, 1)

ans = []
if vertice.count(1) <= n // 3:
    not3 = [i for i in range(1, n+1) if i % 3 != 0]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == 1:
            if num3:
                ans.append(str(num3.pop()))
            else:
                ans.append(str(not3.pop()))
        else:
            if not3:
                ans.append(str(not3.pop()))
            else:
                ans.append(str(num3.pop()))
elif vertice.count(-1) <= n // 3:
    not3 = [i for i in range(1, n+1) if i % 3 != 0]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == -1:
            if num3:
                ans.append(str(num3.pop()))
            else:
                ans.append(str(not3.pop()))
        else:
            if not3:
                ans.append(str(not3.pop()))
            else:
                ans.append(str(num3.pop()))
else:
    num1 = [i for i in range(1, n+1) if i % 3 == 1]
    num2 = [i for i in range(1, n+1) if i % 3 == 2]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == 1:
            if num1:
                ans.append(str(num1.pop()))
            else:
                ans.append(str(num3.pop()))
        else:
            if num2:
                ans.append(str(num2.pop()))
            else:
                ans.append(str(num3.pop()))

print(" ".join(ans))


Measured memory_bytes: 58504
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
 int n;
 cin >> n;
 double x[n],y[n];
 for(int i=0; i<n; i++) cin >> x[i];
 for(int i=0; i<n; i++) cin >> y[i];

 double D=0;
 for(int i=0; i<n; i++) D += abs(x[i] -y[i]);
 printf("%.5f\n",D);
 
 D=0;
 for(int i=0; i<n; i++) D+= pow(abs(x[i]-y[i]), 2);
 D = sqrt(D);
 printf("%.5f\n",D);

 D=0;
 for(int i=0; i<n; i++) D+= pow(abs(x[i]-y[i]), 3);
 D = pow(D, 1.0/3.0);
 printf("%.5f\n" ,D);

 D=0;
 for(int i=0; i<n; i++) if(abs(x[i]-y[i]) > D) D=abs(x[i]-y[i]);
 printf("%.5f\n" ,D); 
}


Measured memory_bytes: 3428
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p, reverse=True)[:x]
q = sorted(q, reverse=True)[:y]

union = sorted(p + q + r, reverse=True)[:x + y]
print(sum(union))



Measured memory_bytes: 114796
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         100000000
#define sc(n)       scanf("%d",&n);
#define ssc(n)      scanf("%s",n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define csc(n)       scanf("%c",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define VI          vector<int>
#define MII         map<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define F(i,a,b)    for(i=a;i<b;i++)
#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         10000009
#define NUM2        1000000000


int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        char c;
        cin >> c;
        if(c=='A')cout << "T" ;
        else if(c=='C')cout << "G" ;
        else if(c=='T')cout << "A" ;
        else cout << "C" ;
    }
}

//printf("Case %d: ",++QQ);


Measured memory_bytes: 3556
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), m = in();
	vector<pair<ll, ll>>stu(n), che(m);
	REP(i, n) {
		ll x = in(), y = in();
		stu[i] = make_pair(x, y);
	}
	REP(i, m) {
		ll x = in(), y = in();
		che[i] = make_pair(x, y);
	}
	REP(i, n) {
		ll ans = INFLL, idx;
		REP(j, m) {
			ll dist = abs(stu[i].first - che[j].first) + abs(stu[i].second - che[j].second);
			if (ans > dist) {
				ans = dist;
				idx = j + 1;
			}
		}
		cout << idx << endl;
	}
}

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  for(int i=0; i<K; i++){
    if (C<=B || C<=A){
    C=C*2;
    }
    else if(B<=A){
    B=B*2;
    }
    else {
    C=C*2;
    }
  }
  if(C<=B || C<=A || B<=A){
      cout << "No" << endl;
      return 0;
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 3556
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, x, y = map(int, readline().split())
    X = list(map(int, readline().split()))
    Y = list(map(int, readline().split()))

    X.append(x)
    Y.append(y)

    if max(X) < min(Y):
        print('No War')
    else:
        print('War')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
n, k = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i)

max = sum = ps[0...k].inject(:+)

(k...n).each do |i|
  sum += ps[i]
  sum -= ps[i - k]
  max = sum if max < sum
end

puts (max + k) / 2.0

Measured memory_bytes: 14980
package main
import (
  "fmt"
  "strconv"
  "strings"
)
const INF = 1000000000
func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int,n)
  for i:=0;i<n;i++ { fmt.Scan(&a[i]) }
  b := make([]int,n)
  for i:=0;i<n;i++ { fmt.Scan(&b[i]) }
  m := 1<<uint(n)
  dp := make([][]int,m)
  for i:=0;i<m;i++ {
    dp[i] = make([]int,51)
    for j:=0;j<51;j++ { dp[i][j] = INF }
  }
  dp[0][0] = 0
  for k:=0;k<m;k++ {
    for i:=1;i<51;i++ { dp[k][i] = min(dp[k][i],dp[k][i-1]) }
    x := popcnt(k)
    for i:=0;i<n;i++ {
      if (k>>uint(i))&1 == 1 { continue }
      v := b[i]
      if (x-i)%2 == 0 { v = a[i] }
      j := k|(1<<uint(i))
      dp[j][v] = min(dp[j][v],dp[k][v]+popcnt(k>>uint(i)))
    }
  }
  x := INF
  for i:=0;i<51;i++ { x = min(x,dp[m-1][i]) }
  if x == INF { x = -1 }
  fmt.Println(x)
}
func min(x,y int) int {
  if x < y { return x }
  return y
}
func popcnt(x int) int {
  s := strconv.FormatInt(int64(x),2)
  return strings.Count(s,"1")
}

Measured memory_bytes: 157420
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[202020];
vector<int>now[2020202];
int to[2020202];
int ans[2020202];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num - 1; i++)scanf("%d", &d[i]);
	for (int i = 0; i <= 2010101; i++)now[i].push_back(i), to[i] = i;
	int s = 0;
	for (int i = num - 2; i >= 2; i--)
	{
		for (int j = 0; j < d[i]; j++)
		{
			int x = to[s + j], y = to[s + d[i] + d[i] - j];
			if (now[x].size() < now[y].size())swap(x, y);
			for (int k = 0; k < now[y].size(); k++)now[x].push_back(now[y][k]), to[now[y][k]] = x;
		}
		s += d[i];
	}
	for (int i = s; i <= s + s; i++)
	{
		for (int j = 0; j < now[to[i]].size(); j++)ans[now[to[i]][j]] = i - s;
	}
	int query;
	scanf("%d", &query);
	for (int p = 0; p < query; p++)
	{
		int z;
		scanf("%d", &z);
		if (z < s)printf("%d\n", d[0] - d[1] + ans[z]);
		else printf("%d\n", d[0] - d[1] + z - s);
	}
}

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

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

  int i, j, k, l, sum, count = 0;

  while (cin >> sum) {
    count = 0;
    for (i = 0; i < 10; i++) {
      for (j = 0; j < 10; j++) {
        for (k = 0; k < 10; k++) {
          for (l = 0; l < 10; l++) {
            if (i + j + k + l == sum) { count += 1; }
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}

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

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= 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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int times(int x, int t) {
    int res = x;
    REP(_, t) res *= 2;
    return res;
}

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    REP(i, k+1) REP(j, k+1) {
        if (i+j != k) continue;

        int B = times(b, i);
        int C = times(c, j);

        if (a < B and B < C) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = b; i >= (a); --i)
#define repdl(i, a, b) for(ll i = b; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int jmp[1000005][26];
int cnt[1000005][26];
int st[200005];
int nid = 1;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n; read(n);
  vector<string> v(n);
  rep(i, 0, n) read(v[i]), reverse(all(v[i]));

  rep(i, 0, n) {
    int freq[26];
    fill(freq, freq + 26, 0);
    for (char c : v[i]) freq[c - 'a']++;
    int ptr = 0;
    for (char c : v[i]) {
      int d = c - 'a';
      if (!jmp[ptr][d]) {
        jmp[ptr][d] = nid++;
      }
      int x = jmp[ptr][d];
      rep(p, 0, 26) if (freq[p]) {
        //write(i, c, ptr, p, (char)(p+'a'));
        cnt[ptr][p]++;
      }
      freq[d]--;
      ptr = x;
    }
  }

  ll ans = 0;
  rep(i, 0, n) {
    int ptr = 0;
    for (int j = 0; j < sz(v[i]) - 1; j++)
      ptr = jmp[ptr][v[i][j] - 'a'];
    //write(i, v[i].back(), cnt[ptr][v[i].back() - 'a']);
    ans += cnt[ptr][v[i].back() - 'a'] - 1;
  }
  write(ans);
}



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

signed main(){

  int n;
  cin>>n;

  auto prime_enum = [](int x){
    vector<int> is_p(x,true);
    is_p[0] = is_p[1] = false;
    for(int p=2;p<x;++p){
      if(is_p[p]){
        for(int q=p+p;q<x;q+=p)is_p[q]=false;
      }
    }
    vector<int> primes;
    primes.reserve(10000);
    for(int p=2;p<x;++p){
      if(is_p[p])primes.emplace_back(p);
    }
    return primes;
  };
  auto primes = prime_enum(55555);

  auto mod_five_one = [](vector<int>const& v){
    vector<int> res;
    res.reserve(100);
    for(auto const& vi:v){
      if(vi%5==1)res.emplace_back(vi);
    }
    return res;
  };

  auto ans = mod_five_one(primes);
  assert(ans.size()>=n);
  for(int i=0;i<n;++i)cout<<ans[i]<<" ";
  cout<<endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

ll n,ans;

void dfs(ll x,bool a,bool b,bool c){
    if(n<x) return;
    if(a&&b&&c) ans++;
    dfs(10*x+3,1,b,c);
    dfs(10*x+5,a,1,c);
    dfs(10*x+7,a,b,1);
}

signed main(){
    cin >> n; ans=0;
    dfs(0,0,0,0);
    cout << ans << endl;
}



Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <limits>


int main()
{
	int N, M;
	std::cin >> N >> M;
	std::vector<int> p(M);
	std::vector<bool> S(M);
	for (int i = 0; i < M; i++)
	{
		std::string a;
		std::cin >> p[i] >> a;
		S[i] = a == "AC";
	}

	std::vector<int> P(N, 0);
	std::vector<bool> AC(N, false);
	for (int i = 0; i < M; i++)
	{
		int q = p[i] - 1;
		if (AC[q]) continue;
		
		if (S[i])
		{
			AC[q] = true;
		}
		else
		{
			P[q]++;
		}
	}

	int count_ac = 0, count_penal = 0;
	for (int i = 0; i < N; i++)
	{
		if (AC[i])
		{
			count_ac++;
			count_penal += P[i];
		}
	}

	std::cout << count_ac << " " << count_penal;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long

int main()
{
    int A , B , K;
    int min=0;
    scanf("%d %d %d",&A,&B,&K);

    if (A>B)min=B;
    else min=A;

    int array[min];
    int idx=1;

    for (int i=min;i>=1;i--)
    {
       if (A%i==0 && B%i==0)
       {
           array[idx]=i;
           idx++;
       }
    }

    printf("%d",array[K]);


    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<stdlib.h>
using namespace std;
int main(){
    int X,Y,x,y,gx,gy,cnt=0,N,in,i,i2;
    cin>>X>>Y>>N;
    cin>>x>>y;
    for(in=1;in<N;in++){
        cin>>gx>>gy;
        while(!(x==gx&&y==gy)){
            if(x==gx){
                cnt+=abs(gy-y);
                y=gy;
                break;
            }
            if(y==gy){
                cnt+=abs(gx-x);
                x=gx;
                break;
            }
            if(x<gx){
                if(y<gy){
                    x++;
                    y++;
                    cnt++;
                }
                else{
                    x++;
                    cnt++;
                }
            }
            else{
                if(y<gy){
                    x--;
                    cnt++;
                }
                else{
                    x--;
                    y--;
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3080
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    string S;
    cin >> S;
    ll answer = 0;

    rep(i, 4) if (S[i] == '+') answer ++; else answer --;
    cout << answer << endl;

    return 0;
}

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;
const double PI = 3.14159;

using namespace std;

int main() {

    int n, m, k;
    cin >> n >> m >> k;
    
    ll a[n], b[m];
    rep(i, n)   cin >> a[i];
    rep(i, m)   cin >> b[i];

    int ans = 0;

    ll bm = 0;
    int bn = 0;
    rep(i, m) {
        bm += b[i];
    }

    bn = m;

    ll anow = 0;
    rep(i, n+1) {

        if (i > 0)
            anow += a[i - 1];

        while (bm > k - anow && anow < k) {
            bn--;
            bm -= b[bn];
        }

        //AA("an:" << i << " bn:" << bn << " sum:" << anow + bm);
        if (anow + bm <= k)
            ans = max(i + bn, ans);
    }

    AA(ans);
}

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

signed main(void){
    int N,M;
    int a,b;
    std::vector<std::vector<int>> edge;
    
    //入力、ついでに辺集合を作る
    std::cin >> N >> M;
    edge.resize(N);
    for(int i=0;i<M;i++){
        std::cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    
    //BFSの準備
    std::vector<int> Ans(N,-1);
    std::vector<bool> visited(N,false);
    
    std::queue<int> Queue;
    Queue.push(0);
    visited[0]=true;
    
    //BFS
    while(!Queue.empty()){
        int t = Queue.front();
        Queue.pop();
        for(int v:edge[t]){
            if(visited[v])continue;
            Queue.push(v);
            Ans[v]=t;
            visited[v]=true;
        }
    }
    
    //Noの条件を満たさないかどうかチェック
    //余談:今回はNoにならないことを示せる
    for(int i=1;i<N;i++){
        if(Ans[i]==-1){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    
    //答えの出力
    std::cout << "Yes" << std::endl;
    for(int i=1;i<N;i++){
        std::cout << Ans[i]+1 << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 10220
// Length of largest subarray with 0 Sum
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int x, y;
	cin >> x >> y;
	int sum = 0;
	bool flag = false;
	for(int i=0;i<=x;i++)
	{
		sum = i*2 + (x-i)*4;
		if(sum==y)
		{
			cout << "Yes";
			flag = true;
			break;
		}
	}
	if(!flag)
		cout << "No";
	return 0;
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()re


int main() {
  vector<vector<int>> c(4, vector<int>(4));
  for (int i = 1; i <= 3; i++){
    for (int j = 1; j <= 3; j++) cin >> c[i][j];
  }
  
  int b1 = c[1][1], b2 = c[1][2], b3 = c[1][3];
  bool flag = true;
  if (!( c[2][1]-b1 == c[2][2]-b2 && c[2][2]-b2 == c[2][3]-b3 )) {
    flag = false;
  }
  if (!( c[3][1]-b1 == c[3][2]-b2 && c[3][2]-b2 == c[3][3]-b3 )) {
    flag = false;
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

using ll = long long;

int main(){
	string s; cin >> s;
	ll n = s.length();
	ll left[n + 24] = {0};
    ll right[n + 24] = {0};
	for(ll i = 0; i < n; ++i){
		if(s[i] == '<'){
			left[i + 1] = left[i] + 1; 
		}else left[i + 1] = 0;
	}
	for(ll i = n; i >= 1; --i){
		if(s[i] == '>'){
			right[i] = right[i + 1] + 1; 
		}else right[i - 1] = 0;
	}
	ll sum = 0;
	if(s[0] == '<'){
		left[0] = 0;
	}
	else if(s[0] == '>'){
		left[0] = max(left[1], right[1]) + 1;
	}
	if(s[n - 1] == '<'){
		right[n] = max(left[n - 1], right[n - 1]) + 1;
	}
	else if(s[n - 1] == '>'){
		right[n] = 0; 
	}
	for(ll i = 0; i < n + 3; ++i){
		sum += max(left[i], right[i]);
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 11532