akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

char s[] = "ENWS";
int rev[128];
int dy[] = {0, -1, 0, 1};
int dx[] = {1, 0, -1, 0};

struct Person {
	int y, x;
	char dir;
	int candy, candx;
	Person(int y, int x, char dir) : y(y), x(x), dir(dir){}
	Person(){}
};

char map[32][32];

void moveIt(vector<Person> &v, int num, int i, int j)
{
	if (map[i][j] == 'X'){
		map[v[num].y][v[num].x] = '.';
		v.erase(v.begin() + num, v.begin() + num + 1);
	}
	else {
		map[v[num].y][v[num].x] = '.';
		v[num].y = v[num].candy; v[num].x = v[num].candx;
		map[v[num].y][v[num].x] = v[num].dir;
	}
}

int main()
{
	int w, h;
	
	for (int i = 0; i < 4; i++) rev[s[i]] = i;
	while (scanf("%d %d", &w, &h) && w){
		vector<Person> v;
		
		for (int i = 0; i < h; i++){
			scanf("%s", map[i]);
			for (int j = 0; j < w; j++){
				if (map[i][j] != 'X' && map[i][j] != '#' && map[i][j] != '.'){
					v.push_back(Person(i, j, map[i][j]));
				}
			}
		}
		
		int time = 0;
		int count[32][32];
		while (time <= 180){
			if (v.size() == 0){
				printf("%d\n", time);
				goto next;
			}
			
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					count[i][j] = 0;
			
			for (int num = 0; num < v.size(); num++){
				v[num].candy = v[num].candx = -1;
				for (int i = 0; i < 4; i++){
					int ndir = (rev[v[num].dir] + 3 + i) % 4;
					int ny = v[num].y + dy[ndir], nx = v[num].x + dx[ndir];
					if (map[ny][nx] == '.' || map[ny][nx] == 'X'){
						v[num].candy = ny; v[num].candx = nx;
						v[num].dir = s[ndir];
						count[v[num].candy][v[num].candx]++;
						break;
					}
				}
			}
			
			for (int i = 0; i < h; i++){
				for (int j = 0; j < w; j++){
					if (count[i][j] == 1){
						for (int num = 0; num < v.size(); num++){
							if (v[num].candy != i || v[num].candx != j) continue;
							moveIt(v, num, i, j);
						}
					}
					else if (count[i][j] > 1){
						int pos = -1, priority = 4;
						for (int num = 0; num < v.size(); num++){
							if (v[num].candy != i || v[num].candx != j) continue;
							int p = rev[v[num].dir];
							p = p < 2 ? (p + 2) : (p - 2);
							if (p < priority){
								pos = num; priority = p;
							}
						}
						
						moveIt(v, pos, i, j);
					}
				}
			}
			time++;
		}
		
		printf("NA\n");
		next:;
	}
	
	return (0);
}

Measured memory_bytes: 1064
let id x = x
let n = Scanf.scanf "%d\n" id
let hn = (n+1) / 2

let array = Array.init n (fun _ -> (Scanf.scanf "%d ") id)
  
let list = Array.to_list array

let rec makelistA c m l =
  if c = hn then l else
    makelistA (c+1) (m+2) (array.(m) :: l)

let rec makelistB c m l =
  if c = n - hn then List.rev l else
    makelistB (c+1) (m+2) (array.(m) :: l)


let anslist = (makelistA 0 ((n+1) mod 2) []) @ (makelistB 0 (n mod 2) [])
    
let ans = Array.of_list anslist

let () =
  let rec output s =
    if s = n then print_string "\n"
    else
      (Printf.printf "%d " ans.(s); output (s+1)) in output 0

Measured memory_bytes: 23552
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 2e5 + 5;
const int MAXD = 1e4 + 5;
const int MOD = 1e9 + 7;
const long double EPS = 1e-4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}


int main(){

        ios::sync_with_stdio(0);
        cin.tie(0);
        long long n;
        cin >> n;
        string ans;
        while(n)
        {
            n--;
            ans.push_back((char)((n % 26 + 'a')));
            n/=26;
        }
        reverse(ans.begin(),ans.end());
        cout << ans;





        
       
}


Measured memory_bytes: 3648
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long[] A;
        static long N;

        static void Main(string[] args)
        {
            N = long.Parse(Console.ReadLine());
            //var c = Console.ReadLine();
            A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            long ans = 0;
            Sort(A);
            Reverse(A);

            for (int i = 1; i < 2; i++)
            {
                ans += A[i - 1];
            }

            var flg = true;
            var cou = 1;
            for (int i = 2; i < N; i++)
            {
                if (flg)
                {
                    flg = false;
                    ans += A[cou];
                }
                else
                {
                    flg = true;
                    ans += A[cou];
                    cou++;
                }
            }
            Console.WriteLine(ans);
            //if(N == 1)
            //{
            //    Console.WriteLine(0);
            //}else if(N == 2)
            //{
            //    Console.WriteLine(A.Sum());
            //}
            //else if(N == 3)
            //{
            //    Console.WriteLine(2*A[2]+A[1]);
            //}
            //else
            //{
            //    Console.WriteLine(Cul());
            //}

        }

        static long Cul()
        {
            long ans = 0;

            for (int i = 0; i < N-2; i++)
            {
                ans += A[i + 2];
            }

            ans += A[N - 3] + A[N - 2];

            return ans;
        }


    }

}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

const int maxn = 1e5 + 5;
int n;
int a[maxn];
int k;
int ans;
int fa[maxn];

vector<int> G[maxn], rG[maxn];

int dfs(int u, int f){
    fa[u] = f;
    int mx = 1;
    for(auto v : rG[u]){
        mx = max(mx, 1 + dfs(v, u));
    }
    if(mx >= k){
        mx = 0;
        if(fa[u] != 1)
            ans++;
    }
    return mx;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    ans = 0;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        if(i == 1){
            if(a[i] != 1){
                ans++;
            }
        }else{
            G[i].push_back(a[i]);
            rG[a[i]].push_back(i);
        }
    }
    dfs(1, 1);
    cout << ans << endl;
    return 0;
}


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

vector<double> prob(3000);
double dp[3001][3001];

double p_calc(int heads, int i, int n)
{
	if(heads >= (n+1)/2)
		dp[heads][i] = 1;

	if(i == n && heads < (n+1)/2) 
		dp[heads][i] = 0;

	if(dp[heads][i] != -1)
		return dp[heads][i];

	dp[heads][i] = prob[i]*p_calc(heads+1, i+1, n) + (1-prob[i])*p_calc(heads, i+1, n);
	return dp[heads][i];
}

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

	for(int i = 0; i < n; i++)
		cin >> prob[i];

	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= n; j++)
			dp[i][j] = -1;

	cout << setprecision(10) <<p_calc(0, 0, n) << endl;
	return 0;
}

Measured memory_bytes: 70784
while True:
    a,op,b = input().split()
    
    a = int(a)
    b = int(b)
    op = str(op)
    
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    elif op == "-":
        print(a*b)
    else :
        break


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string o, e;
  cin >> o >> e;
  rep(i, 100) {
    if (i < o.size()) cout << o[i];
    if (i < e.size()) cout << e[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG printf("Passing Line %d in Function [%s].\n",__LINE__,__FUNCTION__);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;

int n,top;
ll ans;
ll A[MAXN],B[MAXN],C[MAXN];

struct Vector{
    int x;
    ll y;

    Vector() {}
    Vector(int _x,ll _y) : x(_x),y(_y) {}

    friend Vector operator - (const Vector &a,const Vector &b){
        return Vector(a.x - b.x,a.y - b.y);
    }

    friend ll operator * (const Vector &a,const Vector &b){
        return 1ll * a.x * b.y - 1ll * a.y * b.x;
    }
};

Vector st[MAXN];

void Insert(Vector vec){
    while(top > 1 && (vec - st[top]) * (st[top] - st[top - 1]) <= 0)
        top--;
    st[++top] = vec;
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
        scanf("%lld",&A[i]);
    for(int i = 1;i <= n;i++)
        scanf("%lld",&B[i]);
    int pos = max_element(A + 1,A + 1 + n) - A;
    rotate(A + 1,A + pos,A + 1 + n);
    rotate(B + 1,B + pos,B + 1 + n);
    A[n + 1] = A[1];
    B[n + 1] = B[1];
    for(int i = 2;i <= n;i++)
        C[i + 1] = 2 * (B[i] + C[i]) - C[i - 1];
    for(int i = 1;i <= n + 1;i++)
        A[i] -= C[i];
    for(int i = 1;i <= n + 1;i++)
        Insert(Vector(i,A[i]));
    for(int i = 1;i < top;i++){
        int d = st[i + 1].x - st[i].x;
        ans += st[i].y * (d + 1) + st[i + 1].y * (d - 1);
    }
    for(int i = 1;i <= n;i++)
        ans += C[i] * 2;
    printf("%.12lf\n",ans / (2.0 * n));
    return 0;
}

Measured memory_bytes: 11492
#include<iostream>
using namespace std;
#define INF 10000;
int n,m,d,movex[4]={1,0,-1,0},movey[4]={0,1,0,-1},ans=0;char ch[101][101];
void linex(int,int);
void liney(int,int);
int main(){
	cin>>n>>m>>d;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>ch[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(ch[i][j]!='#' ){
			linex(i,j);
			liney(i,j);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
void linex(int i,int j){
	bool bo;
	bo=true;
	for(int k=0;k<d;k++){
		if(k+j>=m){
			bo=false;
			break;
		}
		if(ch[i][j+k]=='#'){
			bo=false;
		}
	}
	if(bo){
		ans++;
	}

}
void liney(int i,int j){
	bool bo;
	bo=true;
	for(int k=0;k<d;k++){
		if(k+i>=n){
			bo=false;
			break;
		}
		if(ch[i+k][j]=='#'){
			bo=false;
		}
	}
	if(bo){
		ans++;
	}
}

Measured memory_bytes: 3084
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int p[] = new int[N];
        for(int i=0;i<N;i++){
            p[i]=sc.nextInt();
        }
        Arrays.sort(p);
        int sum = Arrays.stream(p).sum();
        sum -= p[p.length-1]/2;
        System.out.println(sum);
    }
}


Measured memory_bytes: 27860
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int> a(n);
  rep(i,n) a[i] = i+1;
 
  map<vector<int>, int> mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(a.begin(), a.end()));
 
  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,r;
    char ch;
    scanf("%d %c%d",&a,&ch,&b);
    if(ch=='+')r = a+b;
    else r =a-b;
    printf("%d\n",r);
    return 0;
}


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

const long long INF = 1LL << 60;
template<class T> inline bool chmin(T &a, T b){
    if (a>b) {a = b;return true;}
    return false;
}

int main(){
    int N,K; cin >> N >> K;
    vector<long long> h(N);
    vector<long long> dp(N,INF);
    for(int i = 0;i<N;i++) cin >> h[i];
    dp[0] = 0;
    for(int i = 1;i<N;i++){
        for(int j = 0;j<K;j++){
            if (i-j > 0) chmin(dp[i], dp[i-j-1] + abs(h[i]-h[i-j-1]));
            else break;
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
/**
*   @Author : MeGaCrazy
*   @InitTime : Thu Jul 18 03:14:33 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;

const int N=3e5+7;
int l[N],r[N];
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
    int n;

    cin>>n;
    string a;
    cin>>a;
    for(int i=0,j=n-1;i<n;i++,j--){
    	if(a[i]=='E')l[i]++;
    	if(a[j]=='W')r[j]++;
    	l[i]+=l[i-1];
    	r[j]+=r[j+1];
   
    }
    int best=1e9;
    for(int i=0;i<n;i++){
    		
        int value=(n-(l[i]+r[i]-1));
//	cerr<<l[i]<<" "<<r[i]<<" "<<value<<endl;

    	best=min(best,value);
    }
    cout<<best-1<<endl;

	
   	







}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    set<int>sad;
    for(int i=a;i<a+c;i++)
    {
       if(i>=a&&i<=b)
       {
         sad.insert(i);
       }
    }
    for(int i=(b-c)+1;i<=b;i++)
    {
        if(i>=a&&i<=b)
        {
          sad.insert(i);
        }
    }
    set< int > :: iterator it;
    for(it=sad.begin();it!=sad.end();++it)
    {
        cout<<*it<<NL;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  for (int N, Q; cin >> N >> Q, (N | Q) != 0; ) {
    int date[200] = {};
    rep(i, N) {
      int M; cin >> M;
      rep(j, M) {
        int D; cin >> D;
        date[D]++;
      }
    }

    int best = 0;
    rep(i, 200) if (date[best] < date[i]) best = i;
    
    if (date[best] < Q) cout << 0 << endl;
    else cout << best << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1164
while True:
    (n,x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    
    count = 0
    for a in range(1, n + 1 - 2):
        for b in range(a + 1, n + 1 - 1):
            for c in range(b + 1,n + 1):
                if (a + b + c) == x:
                    count += 1
    print(count) 

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=203,INF=1<<29;

ll comb[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int L,K;cin>>L>>K;
    ll ans=0;
    
    comb[0][0]=1;
    for(int i=1;i<MAX;i++){
        comb[i][0]=1;
        for(int j=1;j<=i;j++){
            comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
        }
    }
    
    for(int i=1;2*i-1<=L;i++){
        for(int j=0;j<=i;j++){
            if(j*1+(i-j)*K+(i-1)*1<=L) ans+=comb[i][j];
        }
        //cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
    
}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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 (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, Y;
        cin >> N >> Y;
        rep(a, 0, 2001) {
                rep(b, 0, 4001) {
                        ll c = N - a - b;
                        if (c < 0) break;
                        //        cout << a << ' ' << b << ' ' << c << endl;
                        if (a*10000 + b*5000 + c*1000 == Y) {
                                cout << a << ' ' << b << ' ' << c << endl;
                                return 0;
                        }
                }
        }       
        cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, -1, 0, 1 };
 
int main(void){
 
    int w, h;
 
    while (cin >> w >> h , w, h){
        bool x_wall[40][40] = { false }, y_wall[40][40] = { false };
        bool used[40][40];
        queue<pair <int, pair<int, int> > > que;
 
        for (int j = 0; j < h; j++){
            for (int i = 0; i < w; i++) used[j][i] = false;
        }
 
        for (int i = 0; i < w; i++) y_wall[0][i] = true;
         
        for (int j = 0; j < h - 1; j++){
            int buff;
            x_wall[j][0] = true;
            for (int i = 1; i < w; i++) cin >> x_wall[j][i];
            x_wall[j][w] = true;
 
            for (int i = 0; i < w; i++) cin >> y_wall[j + 1][i];
             
        }
 
        x_wall[h-1][0] = true;
        for (int i = 1; i < w; i++) cin >> x_wall[h-1][i];
        x_wall[h-1][w] = true;
 
        for (int i = 0; i < w; i++) y_wall[h][i] = true;
 
        que.push(make_pair(1, make_pair(0, 0)));
 
        bool flag = false;
 
        while (!que.empty()){
            pair <int, pair<int, int> > nxy = que.front();
            que.pop();
 
            int x = nxy.second.first;
            int y = nxy.second.second;
            if (used[y][x] || x < 0 || w < x || y < 0 || h < y)continue;
 
            used[y][x] = true;
 
            if (x == w - 1 && y == h - 1){
                cout << nxy.first << endl;
                flag = true;
                while (!que.empty()) que.pop();
                break;
            }

 
            if (!x_wall[y][x] && !used[y][x - 1]) que.push(make_pair(nxy.first + 1, make_pair(x - 1, y)));
            if (!y_wall[y][x] && !used[y - 1][x]) que.push(make_pair(nxy.first + 1, make_pair(x, y - 1)));
            if (!x_wall[y][x + 1] && !used[y][x + 1]) que.push(make_pair(nxy.first + 1, make_pair(x + 1, y)));
            if (!y_wall[y + 1][x] && !used[y + 1][x]) que.push(make_pair(nxy.first + 1, make_pair(x, y + 1)));
 
        }
 
        if (!flag) cout << 0 << endl;
 
    }
 
    return 0;
}

Measured memory_bytes: 3068
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> xs(n, vector<int>(d, 0));
    rep(i, n) rep(j, d) {
        cin >> xs[i][j];
    }
    int ans = 0;
    rep(i, n - 1) {
        for (int j = i + 1; j < n; j++) {
            int dist = 0;
            rep(k, d) {
                dist += (xs[i][k] - xs[j][k])  * (xs[i][k] - xs[j][k]);
            }
            if (ceil(sqrt(dist)) == floor(sqrt(dist))) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
from math import sin,cos,radians
a,b,c=map(int,input().split())
c=radians(c)
s=a*b*sin(c)*0.5
for i in[s,a+b+(a*a+b*b-2*a*b*cos(c))**0.5,s/a*2]:print('%5f'%i)


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

#define int long long
#define pb push_back
#define fi first
#define se second

const int N=1e5+5;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;

int n,ans;
int pset[N],s[N];
vector<ii> vx,vy;
map<ii,int> ma;
priority_queue<iii,vector<iii>,greater<iii> > pq;

bool how_sort(ii a,ii b){
    if(a.se!=b.se)
            return a.se<b.se;
    return a.fi<b.fi;
}

int unionfind(int u){
    return (u==pset[u]) ? u : (pset[u]=unionfind(pset[u]));
}
bool compare(int u,int v){
    return (unionfind(u)==unionfind(v)) ? true :false;
}
void unionset(int i,int j)
{
    int x=unionfind(i),y=unionfind(j);
    if(s[x]>s[y]){
        pset[y]=x;
        s[x]+=s[y];
    }
    else{
        pset[x]=y;
        s[y]+=s[x];
    }
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int cnt=0;
    cin>>n;
    for(int i=1;i<=n;++i){
        int a,b;
        cin>>a>>b;
        if(ma[ii(a,b)])continue;
        ma[ii(a,b)]=++cnt;
        vx.pb(ii(a,b));
        vy.pb(ii(a,b));
        pset[cnt]=cnt;
        s[cnt]=1;
    }
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end(),how_sort);
    
	
    for(int i=1;i<vx.size();++i){
        int a=vx[i].fi-vx[i-1].fi;
        pq.push(iii(a,ii(ma[vx[i]],ma[vx[i-1]])));
	
        int b=vy[i].se-vy[i-1].se;
        pq.push(iii(b,ii(ma[vy[i]],ma[vy[i-1]])));
    }
    while(!pq.empty()){
        iii x=pq.top();
        int w=x.fi,u=x.se.fi,v=x.se.se;
        pq.pop();
        if(!compare(u,v)){
            unionset(u,v);
            ans+=w;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 20828
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N;
        int[] Xi = null;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            Xi = new int[N];
            for (int i = 0; i < N; i++) {
                Xi[i] = sc.nextInt();
            }
        }

        int result = Integer.MAX_VALUE;
        for (int i = 0; i < 101; i++) {
            int temp = 0;
            for(int j : Xi){
                temp += Math.pow(Math.abs(i - j),2);
            }
            if(result > temp){
                result = temp;
            }
        }

        System.out.println(result);
    }
}


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

int main()
{
	int A, B;

	cin >> A >> B;

	int ans = A + B;

	if( ans >= 10 ) {
		cout << "error" << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int w[n];
    for(int i = 0; i < n; i++) cin >> w[i];
    int ans = 100000;
    for(int t = 0; t < n; t++){
        int s1 = 0, s2 = 0;
        for(int i = 0; i < n; i++){
            if(i <= t) s1 += w[i];
            else s2 += w[i];
        }
        if(abs(s1 - s2) < ans) ans = abs(s1 - s2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    char before = s.front();
    int cnt = 0;
    for(char c : s) {
        if(c != before) ++cnt;
        before = c;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
    int n, sum=0;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0; i<n-2; i++){
        string s2 = s.substr(i, 3);
        if(s2 == "ABC") sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ukvc = [ list(map(int,input().split())) for _ in range(n) ]

g = [ [] for _ in range(n) ]
for i in range(n):
    ls = ukvc[i]
    u = ls[0]
    k = ls[1]
    vc = ls[2:]
    for j in range(k):
        v = vc[2*j]
        c = vc[2*j+1]
        g[u].append([c,v])
# print(g)


# Dijkstra法(O(ElogV))
# edge[i] : iから出る道の[重み,行先]の配列
import heapq
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n # True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

d = dijkstra_heap(0,g)

for i in range(n):
    print(i,d[i])


Measured memory_bytes: 6576
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var N, M int
var matrix [8][]int
var ans int

func dfs(done []bool, now, depth int) {
	//再帰の終了条件
	if depth == N-1 {
		ans++
		return
	}

	//訪問中の点を、訪問済みにする
	done[now] = true

	//次の候補について
	for _, nv := range matrix[now] {
		//訪問済みの場合はスキップ
		if done[nv] {
			continue
		}
		//未訪問の場合は、再帰呼び出し
		dfs(done, nv, depth+1)
	}

	//次の候補が無くなったら、自分を未訪問として、次の候補に移る！！
	done[now] = false
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M = nextInt(), nextInt()

	for i := 0; i < M; i++ {
		var a, b int
		a, b = nextInt(), nextInt()
		a--
		b--
		matrix[a] = append(matrix[a], b)
		matrix[b] = append(matrix[b], a)
	}

	done := make([]bool, N)
	ans = 0
	dfs(done, 0, 0)

	fmt.Println(ans)
}


Measured memory_bytes: 640
N, M = map(int, input().split())
LRD = [list(map(int, input().split())) for _ in range(M)]

G = [{} for _ in range(N+1)]
for L, R, D in LRD:
    G[L][R] = D
    G[R][L] = -D

visited = [False] * (N+1)
dist = [0] * (N+1)


def dfs(v):
    q = [v]
    while q:
        cu = q.pop()
        for nx, d in G[cu].items():
            if visited[nx]:
                if dist[nx] != dist[cu] + d:
                    # print(nx, dist[nx], cu, dist[cu], d)
                    print('No')
                    exit()
            else:
                visited[nx] = True
                dist[nx] = dist[cu] + d
                q.append(nx)
    return True


for n in range(1, N+1):
    if not visited[n]:
        dfs(n)
print('Yes')


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

int main(){
	int n;
	cin >> n;
	int counts = 0;
	rep(i,n+1){
		if(to_string(i).size()%2 ==1) counts++;
	}
	cout << counts -1  << endl;
}

Measured memory_bytes: 3764
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    int out = 0;

    for(int i = 0; i < n; i += 2 * d + 1)
        ++out;

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
import math

a,b,x = map(int,input().split())
if x * 2 >= a ** 2 * b:
    y = a ** 2 * b - x
    y /= a
    z = y * 2 / a
    print(math.degrees(math.atan2(z,a)))
else:
    y = x / a
    z = y * 2 / b
    print(math.degrees(math.atan2(b,z)))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;


int main(int argc, const char * argv[]) {
    string s; cin >> s;
    
    cout << (s <= "2019/04/30" ? "Heisei" : "TBD") << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

ll gcd(ll a, ll b) {
    if(a < b){
        return gcd(b, a);
    }
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    if(k > *max_element(a.begin(), a.end())){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    ll g = a.at(0);
    for(ll i = 1; i < n; ++i){
        g = gcd(g, a.at(i));
    }
    if(k % g == 0){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
if __name__ == '__main__':
    N, M = map(int, input().split())
    
    AB = [list(map(int, input().split())) for _ in range(N)]
    count = 0
    pay = 0

    AB = sorted(AB, key=lambda x:x[0])
    
    for ab in AB:
        if count + ab[1] > M:
            pay += ab[0]*(M - count)
            break
        else:
            count += ab[1]
            pay += ab[0]*ab[1]
    print(pay)

Measured memory_bytes: 29796
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

O = list(IS())
E = list(IS())
t = ""
i = 0
for i in range(len(O)):
    a = O[i]
    if len(E) != 0:
        b = E.pop(0)
        t += a + b
    else:
        t += a
print(t)

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool U[105];

int main()
{
    REP(i, 3)
    {
        int n;
        cin >> n;
        n--;
        U[n] = true;
    }

    int s = 0;
    REP(i, 100)
    {
        if (U[i])
            s++;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<vector>

#define LAST '{'
#define MOD 1000000007

using namespace std;

int comb,len,syurui=0;
vector<int> table(100, 0);

long solve(int now,int nokori,int used) {
	if (used==comb) {
		return 1;
	}
	if ( nokori<comb-used || table[now] == 0) {
		return 0;
	}
	else {
		return (solve(now + 1, nokori-1, used) + 
				solve(now + 1, nokori-1, used+1)
				*table[now])%MOD;
	}
}

int main()
{
	string S;
	int N;
	int i,tmp;
	long ans;

	cin >> N;
	cin >> S;
	len = S.length();
	for (i = 0; i < len; i++) {
		tmp = S[i]-'a';
		if ( table[tmp]== 0) {
			syurui++;
		}
		table[tmp]++;
	}
	ans = len;

	sort(table.rbegin(),table.rend());

	for (i = 2; i <= 26; i++) {
		comb = i;
		ans = (ans + solve(0, syurui, 0))%MOD;
	}


	cout << ans << endl;

	return 0;
}


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

int main(){
  string S,T;
  int A,B;
  string U;
  cin >> S >> T >> A >> B >> U;
  if(S == U)A--;
  else if(T == U)B--;
  cout << A << ' ' << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    long long int lis[200003];
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        long long int a,b;
        cin>>a>>b;
        lis[i]=b*1000000+a;
    }
    sort(lis,lis+N);
    int flg=1;
    long long int now=0;
    for(int i=0;i<N;i++){
        now+=lis[i]%1000000;
        if(lis[i]/1000000<(long long int)now){
            flg=0;
            break;
        }
    }
    if(flg)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 4644
N = int(input())
A = list(input())

res = N
num = [0] * (N+1)
for i in range(0, N):
    num[i + 1] = num[i]
    if A[i] == 'W':
        num[i + 1] += 1
for i in range(1, N + 1):
    res = min(res, num[i - 1] + (N - i) - (num[N] - num[i]))

print(res)

Measured memory_bytes: 19316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef unsigned long long ll;

#define _ { \
	ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
}

int main(){
   _;
   ll h,w;cin>>h>>w;
   ll a=h*w;
   if(h==1||w==1)cout<<1;
  else if(a%2==0)cout<<a/2;
   else cout<<a/2+1;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 998244353ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    s64 n, s;
    cin >> n >> s;
    vs64 a(n);
    rep (i, n) cin >> a[i];

    s64 dp[n + 1][s + 1][3];
    rep (i, s + 1) rep (j, 3) dp[0][i][j] = 0;
    dp[0][0][0] = 1;

    rep (i, n)
    {
        rep (j, s + 1)
        {
            if (j >= a[i])
            {
                dp[i + 1][j][0] = dp[i][j][0];
                dp[i + 1][j][1] = (dp[i][j][1] + (dp[i][j - a[i]][1] + (i + 1) * dp[i][j - a[i]][0] % MOD)) % MOD % MOD;
                dp[i + 1][j][2] = (dp[i][j][2] + ((n - i) * dp[i][j - a[i]][1] % MOD + (i + 1) * (n - i) * dp[i][j - a[i]][0] % MOD) % MOD) % MOD;
            }
            else
            {
                dp[i + 1][j][0] = dp[i][j][0];
                dp[i + 1][j][1] = dp[i][j][1];
                dp[i + 1][j][2] = dp[i][j][2];
            }
        }
    }

    cout << dp[n][s][2] << "\n";
    return 0;
}



Measured memory_bytes: 211328
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

int fact[N], infact[N];

int qmi(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)	res = (ll)res * a % mod;
		a = (ll)a * a % mod;
		b >>= 1;
	}
	return res;
}

void init()
{
	fact[0] = 1, infact[0] = 1;
    for(int i = 1; i < N; ++i)
    {
        fact[i] = (ll)fact[i - 1] * i % mod;
        infact[i] = (ll)infact[i - 1] * qmi(i, mod - 2) % mod;
    }
}

int C(int a, int b)
{
	return (ll)fact[a] * infact[b] % mod * infact[a - b] % mod;
}

int main()
{
	int k;
	string s;
	cin >> k >> s;
	
	int len = s.length();
	int n = k + len;
	init();						// 预处理阶乘
	
	int ans = 0;
	for(int i = len; i <= n; i++)
	{
		int t = (ll)C(i - 1, len - 1) * qmi(25, i - len) % mod * qmi(26, n - i) % mod;
		ans = (ans % mod + t % mod) % mod;
	}
	cout << ans << endl;
	return 0;
}



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

//const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
const ll mod = 998244353;

vector<ll> dp(440000);

int main(void)
{
    ll n, k;
    cin >> n >> k;
    vector<P> a(k);
    rep(i,k){
        ll l, r;
        cin >> l >> r;
        r++;
        a[i] = {l, r};
    }
    dp[1] = 1;
    dp[2] = -1;
    REP(i,1,n+1){
        dp[i] += dp[i-1];
        rep(j,k){
            ll l, r;
            l = a[j].first;
            r = a[j].second;
            dp[i+l] += dp[i];
            dp[i+l] %= mod;
            dp[i+r] -= dp[i];
            dp[i+r] =  (dp[i+r]+mod)%mod;
        }
    }
    cout << (dp[n]%mod+mod)%mod << endl;
    return 0;
}


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

int main(void) {
  vector<bool> v(123456, true);
  v[0] = v[1] = false;
  for (int i = 2; i * i <= 123456; i++) {
    if (!v[i]) continue;
    for (int j = 2 * i; j < 123456; j += i) {
      v[j] = false;
    }
  }

  vector<int> sum(123456, 0);
  for (int i = 1; i < 123456; i++) {
    int plus = 0;
    if (v[i] && v[(i + 1) / 2]) {
      plus = 1;
    }
    sum[i] = sum[i - 1] + plus;
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int l, r;
    cin >> l >> r;
    cout << sum[r] - sum[l - 1] << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;



int main(){

  ll n,k,c;cin>>n>>k>>c;
  string s;cin>>s;
  ll l[k],r[k];
  ll p=0;
  rep(i,0,n){
    if(s[i]=='o'){l[p]=i,p++,i+=c;
    if(p==k)break;}
  }
  p=0;
  repr(i,n-1,0){
    if(s[i]=='o'){r[p]=i;p++,i-=c;
    if(p==k)break;}
  }
  reverse(r,r+k);

  rep(i,0,k){
    if(l[i]==r[i])out(l[i]+1);
  }

  return 0;
}


Measured memory_bytes: 4996
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
 
#maincode-------------------------------------------------

d,t,s = inm()
if d - t * s > 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9248
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
vvi out(10,vi(10)),in(10,vi(10)),tmp(10,vi(10));
vi top(10);
int dx[]={-1,0,0,0,1};
int dy[]={0,-1,0,1,0};
bool solve2(){
	rep(i,10)rep(j,10)out[i][j]=0;
	tmp=in;
	rep(i,10)if(top[i]){
		out[0][i]=1;
		rep(j,5){
			int nx=dx[j];
			int ny=i+dy[j];
			if(nx>=0&&nx<10&&ny>=0&&ny<10)tmp[nx][ny]=!tmp[nx][ny];
		}
	}
	loop(i,1,10)rep(j,10)if(tmp[i-1][j]){
		out[i][j]=1;
		rep(k,5){
			int nx=i+dx[k];
			int ny=j+dy[k];
			if(nx>=0&&nx<10&&ny>=0&&ny<10)tmp[nx][ny]=!tmp[nx][ny];
		}
	}
	bool h=true;
	rep(i,10)rep(j,10)if(tmp[i][j])h=false;
	return h;
}
bool solve(int a){
	if(a==10)if(solve2())return true;
	else return false;
	
	top[a]=1;
	if(solve(a+1))return true;
	top[a]=0;
	if(solve(a+1))return true;
	return false;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		rep(i,10)top[i]=0;
		rep(i,10)rep(j,10)cin>>in[i][j];
		solve(0);
		rep(i,10){
			rep(j,9)cout<<out[i][j]<<" ";
			cout<<out[i][9]<<endl;
		}
	}
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>

using namespace std;

int main()
{
  int Cba = 0;
  int Cb_ = 0;
  int C_a = 0;
  int C__ = 0;

  int N;
  cin >> N;

  int ans = 0;

  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    if (s.size() >= 2) {
      for (int pos = 0; pos < (int)s.size() - 1; ++pos) {
	if (s[pos] == 'A' and s[pos + 1] == 'B') {
	  ++ans;
	}
      }
    }
    if (s.front() == 'B' and s.back() == 'A') ++Cba;
    else if (s.front() == 'B') ++Cb_;
    else if (s.back() == 'A') ++C_a;
    else ++C__;
  }

  if (Cba >= 2) {
    ans += Cba - 1;
    Cba = 1;
  }

  if (Cba == 1) {
    if (C_a > 0) {
      ++ans;
      --C_a;
    }
    if (Cb_ > 0) {
      ++ans;
      --Cb_;
    }
  }

  ans += min(C_a, Cb_);
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int w,h,n,x,y,a,x1,x2,y1,y2;
	cin >> w >> h >> n;
	x1=0;
	x2=w;
	y1=0;
	y2=h;
	while (n--) {
		cin >> x >> y >> a;
		if (a==1) {
			x1=max(x,x1);
		} else if (a==2) {
			x2=min(x,x2);
		} else if (a==3) {
			y1=max(y,y1);
		} else {
			y2=min(y,y2);
		}
	}
	cout << max(0,(x2-x1))*max(0,(y2-y1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define NOTUSED 0
#define INF 2147483647
#define MINUS_INF -2147483648
using Graph = vector<vector<int>>;

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

    vector<int> r(n);
    REP(i,n){
        cin>>r[i];
    }

    int maxv=MINUS_INF;
    int minv=INF;

    REP(i,n){
        maxv=max(maxv,r[i]-minv);
        minv=min(minv,r[i]);
    }

    cout<<maxv<<endl;
}


Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
n = int(input())
A = [int(n) for n in input().split()]
q = int(input())
M = [int(n) for n in input().split()]

numbers = [0]

for a in A:
    numbers = numbers + [n+a for n in numbers]

for m in M:
    if m in numbers:
        print("yes")
    else:
        print("no")

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

using namespace std;
const int MAXN=51,ZERO=2550;
typedef long long ll;
int n,a,x,cur;
ll dp[2][2*ZERO];

int main() 
{
	scanf("%d%d",&n,&a);
	dp[cur^1][ZERO]=1;
	for (int i=1;i<=n;i++,cur^=1)
	{
		scanf("%d",&x);x-=a;
		for (int j=MAXN;j+MAXN<2*ZERO;j++)
			dp[cur][j]=dp[cur^1][j]+dp[cur^1][j-x];
	}
	printf ("%lld\n",dp[cur^1][ZERO]-1);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n;
ll a[100000], b[100000];
vector<ll> v;

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll sum = 0;
    ll cnt = 0;
    rep(i,n) {
        if (a[i] < b[i]) {
            cnt++;
            sum += b[i] - a[i];
        }
    }
    rep(i,n) {
        if (a[i] > b[i]) v.push_back(a[i]-b[i]);
    }
    sort(v.begin(), v.end(), greater<ll>());
    rep(i,v.size()) {
        if (sum <= 0) break;
        cnt++;
        sum -= v[i];
    }
    if (sum > 0) cout << -1 << endl;
    else cout << cnt << endl;
}



Measured memory_bytes: 2428
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n,m = map(int, readline().split())
  a = list(map(int, readline().split()))
  total = sum(a)
  count = 0
  for i in a:
    if i>=total/(4*m):
      count +=1
  if count>=m:
    print('Yes')
  else:
    print('No')
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5604
#include<iostream>
using namespace std;
int main()
{
  int N;
  cin >> N ;

  for(int i=1;i<10;i++){
   for(int j=1;j<10;j++){
     if(N==i*j){ 
       cout<<"Yes";
       return 0;
     }
   }
  }
  cout<<"No";
}

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

int main(){
    int r, g, k, n;
    cin >> r >> g >> k >> n;
    long long ans = 0;
    int a = 0, b = 0;
    while (a * r + b * g <= n){
        while (a * r + b * g <= n){
            if ((n - r * a - g * b) % k == 0){
                ans++;
            }
            b++;
        }
        b = 0;
        a++;
    }
    cout << ans;
}


Measured memory_bytes: 256
N, M, D = [int(_) for _ in input().split()]
#A[i]∈[0,n)で考察したときの解と一致
#x∈[0,N-D) and D<N ⇒ x+D∈[0,N)
#x∈[D,N) and D<N⇒ x-D∈[0,N)
if D == 0:
    ans = (M - 1) / N
elif D < N - D:
    ans = (2 * (N - 2 * D) + 2 * D) * (M - 1) / N / N
elif D < N:
    ans = (2 * N - 2 * D) * (M - 1) / N / N
else:
    ans = 0
print(ans)


Measured memory_bytes: 9080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
int a,b;
int main()
{
	scanf("%d %d",&a,&b);
	if(b<a) {int c=a;a=b;b=c;
	}
	int ans=(a+b)/2;	
	if(ans*2==a+b) printf("%d\n",ans);
	else printf("IMPOSSIBLE");
}

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

int main(){
  int N;
  int sum1=0,sum2=0;
  cin>>N;

  vector<int> a(N);

  rep(i,N){
    cin>>a.at(i);
  }  

  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  for(int i=0;i<N;i++){
    if(i%2){
      sum2+=a.at(i);
    }
    else{
      sum1+=a.at(i);
    }
  }

  #ifdef _DEBUG_
  cout<<sum1<<endl<<sum2<<endl;
  #endif

  cout<<sum1-sum2<<endl;
}

Measured memory_bytes: 256