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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;} cout << endl;
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vvi Graph;

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

    int n;
    cin >> n;

    rep2(ma, 1, n + 1) {
        if (n - ma <= (ma - 1) * ma / 2) {

            // 構成可能
            vector<int> a;
            rep2(i, 1, ma) {
                a.emplace_back(i);
            }

            reverse(all(a));

            vector<int> ans;
            ans.emplace_back(ma);
            int j = 0;
            int t = 0;
            while (j < a.size() && t + a[j] <= n - ma) {
                ans.emplace_back(a[j]);
                t += a[j];
                j++;
            }
            if (n - ma - t > 0) ans.emplace_back(n - ma - t);

            rep(i, ans.size()) {
                cout << ans[i] << endl;
            }

            return 0;
        }
    }
}


Measured memory_bytes: 384
s = list(map(int, input().split()))
if s[0] == s[1]:
    if s[1] == s[2]:
        print("No")
    else:
        print("Yes")
else:
    if s[1] == s[2]:
        print("Yes")
    elif s[0] == s[2]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll n; cin>>n; ll a[n];
	ff(0,n) cin>>a[i];
	double c=(accumulate(a,a+n,0))/(double)n;
	c=round(c);
	ll ans=0;
	ff(0,n)
	{
		ll x=abs(c-a[i]);
		ans+=x*x;
	}
	cout<<ans;
}

int main()
{
	solve();
}

Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string a,b,c;cin>>a>>b>>c;
  bool flag=true;
  if(a[a.length()-1]!=b[0])flag=false;
  if(b[b.length()-1]!=c[0])flag=false;
	if(flag){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 1;
        int MAXN = (int)1e6;
        boolean[] present = new boolean[MAXN];
        while (true) {
            if (present[n]) {
                break;
            }
            present[n] = true;
            if ((n & 1) == 1) n = 3 * n + 1;
            else n /= 2;
            ans += 1;
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 36736
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int, int> pint;
#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main()
{
    ll n, k, q;
    cin >> n >> k;
    vl p(k);
    ll now = 0, ans = 0;
    rep(i, n)
    {
        cin >> q;
        if (i < k)
        {
            now += q + 1;
            ans += q + 1;
            p[i] = q;
        }
        else
        {
            now += q - p[i % k];
            ans = max(ans, now);
            p[i % k] = q;
        }
    }
    if (ans % 2 == 1)
    {
        ans /= 2;
        cout << ans << ".5" << endl;
    }
    else
    {
        ans /= 2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }

    ll ans = 0;
    for(ll i=0;i<n;++i){
        bool flag = true;
        for(ll j=2;j<=sqrt(a[i]);++j){
            if(a[i] == j)continue;
            if(a[i] % j == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define PB push_back
#define int ll

int n;
int p[1000000];
int a[1000000];
int b[1000000];

signed main(){
  cin>>n;
  rep(i,n){
    cin>>p[i];
  }

  rep(i,n){
    a[i] = (i+1)*n;
    b[n-i-1] = (i+1)*n;
  }

  rep(i,n){
    a[p[i]-1]+=i;
  }

  rep(i,n){
    if(i==0) cout<<a[i];
    else cout<<' '<<a[i];
  }
  cout<<endl;
  rep(i,n){
    if(i==0) cout<<b[i];
    else cout<<' '<<b[i];
  }

  cout<<endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;

    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      int X = sc.nextInt();
      int max = X/100;
      int min = X/105;
      int amari = X%100;
      
	  for(int i=max;i>=min;i--){
        if(amari<=i*5){
          System.out.println("1");
          return;
        }
        amari=amari+100;
      }
      System.out.println("0");
      

    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}


Measured memory_bytes: 21844
n = int(input())
ans = {
    'AC': 0,
    'WA': 0,
   	'TLE': 0,
   	'RE': 0
}

for i in range(n):
  x = input()
  ans[x] += 1

for i in list(ans.keys()):
  print(i + ' x '+str(ans[i]))


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

int main(){
	int n;
	scanf("%d", &n);
	if(111>=n) printf("111");
	else if(222>=n) printf("222");
	else if(333>=n) printf("333");
	else if(444>=n) printf("444");
	else if(555>=n) printf("555");
	else if(666>=n) printf("666");
	else if(777>=n) printf("777");
	else if(888>=n) printf("888");
	else if(999>=n) printf("999");
	
	return 0;
}

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

class WeightedUnionFind {
public:
    vector<int> parents, rank, diff_weight;

    WeightedUnionFind(int n) : parents(n), rank(n), diff_weight(n) {
        for (int i = 0; i < n; i++) {
            parents[i] = i;
            rank[i] = 0;
            diff_weight[i] = 0;
        }        
    }

    int root(int x) {
        if (parents[x] == x) { // root
            return x;
        } else {
            int r = root(parents[x]);
            diff_weight[x] += diff_weight[parents[x]];
            return parents[x] = r;
        }
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y, int w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;

        if (rank[x] < rank[y]) {
            swap(x, y);
            w = -w;
        }

        if (rank[x] == rank[y]) ++rank[x];
        parents[y] = x;

        diff_weight[y] = w;

        return true;
    }

    int weight(int x) {
        root(x);
        return diff_weight[x];
    }

    int diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(void) {

    int n, q; cin >> n >> q;
    WeightedUnionFind wuf(n);

    for (int i = 0; i < q; i++) {
        int type; cin >> type;
        if (type == 0) {
            int x, y, z; cin >> x >> y >> z;            
            wuf.unite(x, y, z);
        } else if (type == 1) {
            int x, y; cin >> x >> y;
            if (!wuf.isSame(x, y)) cout << "?" << endl;
            else cout << wuf.diff(x, y) << endl;
        }
    }

    return 0;
}


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

string s, t, u;
int a, b;

int main()
{
	cin >> s >> t >> a >> b >> u;

	if (u == s)
		cout << a - 1 << " " << b << endl;
	else
		cout << a << " " << b - 1 << endl;

	return 0;
}

Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(N,M,C);
    vector<int> A(M),B(M);
    int count = 0;
    rep(i,M) cin >> B[i];
    rep(i,N){
        rep(i,M) cin >> A[i];
        int sum = 0;
        rep(i,M) sum += A[i]*B[i];
        if(sum+C>0) count++;
    }
    cout << count << nn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, k, q, a;
    cin >> n >> k >> q;
    vector<ll> pts(n, k-q);
    while (q--) {
        cin >> a;
        pts[a-1]++;
    }
    fore(i,0,n) {
        if (pts[i] > 0) cout << "Yes\n";
        else cout << "No\n";
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N, K;
    cin >> N >> K;

    cout << K * static_cast<ll>(pow(K - 1, N - 1)) << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

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

  int x=max(a, c);
  int y=min(b, d);

  if(x>y){
    cout << 0 << endl;
  } else {
    cout << y-x << endl;
  }

  return 0;
}

Measured memory_bytes: 256
// AOJ 2253

#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair <int, int> P;

int field[200][200];
int wall[200][200];
int num[200][200];
int dx[] = {1, 1, 0, -1, -1, 0}, dy[] = {1, 0, -1, -1, 0, 1};
int t;

int main(void)
{
	int n;
	while (cin >> t >> n){
		if (t == 0 && n == 0) break;
		int y, x;
		for (int i = 0; i < 200; i++){
			for (int j = 0; j < 200; j++){
				field[i][j] = 0;
				num[i][j] = 0;
				wall[i][j] = 0;
			}
		}

		for (int i = 0; i < n; i++){
			cin >> x >> y;
			y += 100;
			x += 100;
			wall[y][x] = 1;
		}
		int sx, sy;
		cin >> sx >> sy;
		sx += 100;
		sy += 100;
		field[sy][sx] = t + 1;

		int ret = 0;
		queue <P> q;
		q.push(P(sy, sx));
		while (q.size()){
			P p = q.front();
			q.pop();
			int y = p.first, x = p.second;
			// cout << "DEBUG : " << y-100 << " " << x-100 << " " << field[y][x] << endl;
			// field[p.first][p.second] |= 1;
			// さいごのたーん
			if (field[y][x] == 1) break;
			for (int i = 0; i < 6; i++){
				int ny = y + dy[i], nx = x + dx[i];
				if (ny < 0 || nx < 0 || 200 <= ny || 200 <= nx) continue;
				if (field[ny][nx] == 0 && wall[ny][nx] == 0){
					field[ny][nx] = (field[y][x] - 1);
					q.push(P(ny, nx));
				}
			}
		}

		for (int i = 0; i < 200; i++){
			for (int j = 0; j < 200; j++){
				if (0 < field[i][j]) {
					ret++;
				}
			}
		}

		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1688
X, N = map(int, input().split())

if N == 0:
    print(X)
else:
    p_list = map(int, input().split())

    p_set = set(p_list)
    new_list = []
    new_list.append(0)
    new_list.append(101)
    for i in range(1, 101):
        if i in p_set:
            pass
        else:
            new_list.append(i)

#    print(new_list)

    min_x = 100 #絶対値の最小
    min_diff = 100
    for x in new_list:
        if abs(x - X) <= min_diff:
            if min_diff == abs(x - X):
                if x < min_x:
                    min_x = x
            else:
                min_x = x
                min_diff = abs(x - X)
            
        else:
            pass
    print(min_x)

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

const int INF=123456789;

typedef pair<int,int> P;

char maze[101][101];
int H,W;

int d[101][101];

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

//sxsyからgxgyへの最短距離を求める

int bfs(int sy,int sx,int gy,int gx){
  if(maze[sy][sx]=='#' || maze[gy][gx]=='#') return 123456789;
  queue<P> que;
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++){
       d[i][j]=INF;
     }
   }
  que.push(P(sy,sx));
  d[sy][sx]=0;

  while(que.size()){
    P p=que.front();que.pop();
    if(p.second==gx&&p.first==gy) break;

    for(int i=0;i<4;i++){
      int nx=p.second+dx[i], ny=p.first+dy[i];
      if(0<=nx&&nx<W&&0<=ny&&ny<H&&maze[ny][nx]!='#'&&d[ny][nx]==INF){
        que.push(P(ny,nx));
        d[ny][nx] = d[p.first][p.second]+1;
      }
    }
  }
  //cout<<sx<<sy<<gx<<gy<<endl;
  //cout<<d[0][2]<<endl;
  //cout<<maze[gx][gy]<<endl;
  //cout<<d[gy][gx]<<endl;

  return d[gy][gx];
}

void solve(){

}

int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++) for(int j=0;j<W;j++){
    cin>>maze[i][j];
  }
  /*
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++){
    cout<<maze[i][j];
  }
  cout<<endl;
}
*/
int res = bfs(2,0,0,4);
//cout<<res<<endl;
  int ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      for(int k=0;k<H;k++){
        for(int l=0;l<W;l++){
          int res = bfs(i,j,k,l);
          //if(i==2&&j==0&&k==0&&l==4)cout<<res<<endl;
          //if(i==2&&j==3&&k==0&&l==4)cout<<res<<endl;
          if(res<401){
            //if(res>=0)cout<<i<<j<<k<<l<<res<<endl;

           ans = max(ans, res);
         }
        }
      }
    }
  }
//cout<<bfs(2,0,0,4)<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,a,b,c,d;

    cin >> n >> a >> b >> c >> d;

    auto solve = [=](LL k) -> bool{
        LL min = c*(n-1-k) - d*(k);
        LL max = d*(n-1-k) - c*(k);
        return ((b-a) >= min && (b-a) <= max);
    };

    for(LL i = 0; i <= n-1; i++){
        if(solve(i)){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
def resolve():
	a = [1, 3, 5, 7, 8, 10, 12]
	b = [4, 6, 9, 11]
	c = [2]

	x, y = map(int, input().split())
	if x in a and y in a:
		print("Yes")
	elif x in b and y in b:
		print("Yes")
	elif x in c and y in c:
		print("Yes")
	else:
		print("No")
resolve()

Measured memory_bytes: 3064
{-# LANGUAGE RankNTypes #-}

addA x tp = \cont -> tp (\a b c -> cont (a+x) b c)
addB x tp = \cont -> tp (\a b c -> cont a (b+x) c)
addC x tp = \cont -> tp (\a b c -> cont a b (c+x))

existZero = \a b c -> a==0 || b==0 || c==0
cost ta tb tc = \a b c -> abs (ta-a) + abs (tb-b) + abs (tc-c)

inf = 10^12

solv a b c ls = go ls (\cont -> cont 0 0 0) where
  go :: [Int] -> (forall c. (Int -> Int -> Int -> c) -> c) -> Int
  go [] t
    | t existZero = inf
    | otherwise   = (t $ cost a b c) - 30
  go (x:xs) t
    = min (min (10 + go xs (addA x t)) (10 + go xs (addB x t)))
          (min (10 + go xs (addC x t)) (go xs t))

main = do
  [n,a,b,c] <- map read . words <$> getLine :: IO [Int]
  xs <- map read . words <$> getContents :: IO [Int]
  print $! solv a b c xs


Measured memory_bytes: 1020
def main():
    N, D = map(int, input().split(" "))
    X = []
    result = 0
    for n in range(N):
        X.append(list(map(int, input().split(" "))))
    for i in range(N):
        for j in range(i + 1, N):
            dist = 0
            for d in range(D):
                dist += (X[i][d] - X[j][d]) ** 2
            if float.is_integer(dist ** 0.5):
                result += 1
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a: Vec<u64> = (&mut iter).take(n).map(|x| x.parse().unwrap()).collect();
    
    let mut ret = 0;
    for i in 0..n {
        let pf = prime_factors(a[i]);
        ret += *pf.get(&2).unwrap_or(&0);
    }
    println!("{}", ret);
}

#[doc = " n>=1"]
#[allow(dead_code)]
fn prime_factors(mut n: u64) -> std::collections::HashMap<u64, u64> {
    let mut ret = std::collections::HashMap::new();
    {
        let mut i = 2;
        while i * i <= n {
            while n % i == 0 {
                *ret.entry(i).or_insert(0) += 1;
                n /= i;
            }
            i += 1;
        }
    }
    if n != 1 {
        ret.insert(n, 1);
    }
    ret
}


Measured memory_bytes: 4352
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, int> pdd;

const ll mod = 1e9 + 7;
const int N = 1e2 + 10, M = 1e3 + 10;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int eps = 1e-6;

#define pi acos(-1)
#define mk make_pair

int num[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int k;
    cin >> k;
    cout << num[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<string>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main()
{
	int n,m,flg=0,a[1000];
    cin>>n>>m;
    if(n==1&&!m){
        cout<<0<<endl;
        return 0;
    }
    memset(a,-1,sizeof(a));
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        if(n!=1&&x==1&&y==0){
            flg=1;
        }else if(a[x]==-1){
            a[x]=y;
        }else{
        	if(y==a[x]) flg=0;
        	else flg=1;
        }
    }
    if(flg){
        cout<<"-1\n";
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(a[i]==-1&&i==1){
        	cout<<1; continue;
		}
        else if(a[i]==-1){
        	cout<<0; continue;
		}
        cout<<a[i];
    }
    return 0;
 } 

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

typedef pair <int, int> ii;

int n, q;
vector <ii> seq;
set <int> S;

int main()
{
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; i++) {
        int s, t, x; scanf("%d %d %d", &s, &t, &x);
        seq.push_back(ii(s - x, x));
        seq.push_back(ii(t - x, -x));
    }
    sort(seq.begin(), seq.end());
    int pnt = 0;
    while (q--) {
        int d; scanf("%d", &d);
        while (pnt < seq.size() && seq[pnt].first <= d) {
            if (seq[pnt].second < 0) S.erase(-seq[pnt].second);
            else S.insert(seq[pnt].second);
            pnt++;
        }
        if (S.empty()) printf("-1\n");
        else printf("%d\n", *S.begin());
    }
    return 0;
}


Measured memory_bytes: 13804
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

int n;
int grd[110][110];
int xx[110],yy[110];

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+ch-48;
		ch=gc();
	}
	return rt*sign;
}
inline int mx(int a,int b){return a>b?a:b;}
inline int gh(int cx,int cy,int ch,int x,int y){return mx(0,ch-abs(cx-x)-abs(cy-y));}
int main(){
	n=readint();
	int x,y;
	int hest=0,hestx,hesty,hid;
	rep(i,1,n){
		x=readint(),y=readint();
		xx[i]=x,yy[i]=y;
		grd[x][y]=readint();
		if(grd[x][y]>hest){
			hest=grd[x][y];
			hestx=x,hesty=y;
			hid=i;
		}
	}
	rep(i,0,100){
		rep(j,0,100){
			bool ok=true;
			int ch=grd[hestx][hesty]+abs(i-hestx)+abs(j-hesty);
			rep(k,1,n){
				if(k==hid)continue;
				if(gh(i,j,ch,xx[k],yy[k])!=grd[xx[k]][yy[k]]){
					ok=false;
					break;
				}
			}
			if(ok){
				printf("%d %d %d",i,j,ch);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import itertools
import collections
import bisect

# bin(10*12) = '0b1110100011010100101001010001000000000000' -> 40桁あればよい
def calc(x, b):
    if b == 0:
        return x // 2 + x % 2
    base = 2 ** b
    if x < base:
        return 0

    # return base * (x // base) // 2
    if (x // base) % 2:
        if x // base == 1:
            return x % base + 1
        else:
            return base * ((x // base) // 2) + x % base + 1
    else:
        return base * (x // base) // 2


def main():
    A, B = map(int, input().split())

    bits = []
    for i in range(41):
        a = calc(max(0, A-1), i)
        b = calc(max(0, B), i)
        bits.append(abs(b - a) % 2)

    # for i in range(20):
    #     print("{} {} {} {}".format(calc(i, 3), calc(i, 2), calc(i, 1), calc(i, 0)))
    # exit()

    # print(bits)
    ans = 0
    for i in range(len(bits)):
        ans += bits[i] * (2 ** i)
    print(ans)

if __name__ == '__main__':
    main()


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

stairs =[1, 1] + [0] * (n - 1)

for _ in range(m):
  stairs[int(input())] = "broken"
  
for i in range(2, n + 1):
  if stairs[i] != "broken":
    if stairs[i - 2] != "broken":
      stairs[i] += stairs[i - 2]
    if stairs[i - 1] != "broken":
      stairs[i] += stairs[i - 1]

print(stairs[-1] % 1000000007)

Measured memory_bytes: 462692
from math import sqrt

Q=int(input())
ans=[]
for i in range(0,Q):
    a,b=map(int,input().split())
    if a!=b:
        r=int(sqrt(a*b))
        if r*(r+1)<a*b:
            ans.append(2*r-1)
        else:
            if r**2==a*b:
                ans.append(2*r-3)
            else:
                ans.append(2*r-2)
    else:
        ans.append(2*a-2)


for i in range(0,Q):
    print(ans[i])

Measured memory_bytes: 38384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  int count[4] = {0,0,0,0};
  rep(i,3){
      int a,b;
      cin >> a >> b;
      count[a-1]++;
      count[b-1]++;
  }
  bool f = true;
  rep(i,4){
      if(count[i] > 2 || count[i] == 0){
          f = false;
      }
  }
  if(f){
      P("YES");
  }
  else{ 
      P("NO");
  }

}

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


Measured memory_bytes: 256
n = gets.to_i
hs = Hash.new(0)
n.times do
  s = gets.chomp
  pr = s[0]
  su = s[-1]
  hs["AB"] += s.scan("AB").size
  if pr + su == "BA"
    hs["BA"] += 1
  elsif su == "A"
    hs["_A"] += 1
  elsif pr == "B"
    hs["B_"] += 1
  end
end

if hs["_A"] > 0 && hs["B_"] > 0
  cnt = [hs["_A"], hs["B_"]].min
  hs["_A"] -= cnt
  hs["B_"] -= cnt
  hs["AB"] += cnt
elsif hs["_A"] > 0 && hs["BA"] > 0
  cnt = [hs["_A"], hs["BA"]].min
  hs["_A"] -= cnt
  hs["BA"] -= cnt
  hs["AB"] += cnt
elsif hs["B_"] > 0 && hs["BA"] > 0
  cnt = [hs["_A"], hs["BA"]].min
  hs["BA"] -= cnt
  hs["B_"] -= cnt
  hs["AB"] += cnt
elsif hs["BA"] > 1
  hs["AB"] += hs["BA"] - 1
  hs["BA"] = 0
else
  puts hs["AB"]
  exit
end
puts hs["AB"] + (hs["BA"] + [hs["B_"], hs["A_"]].min)

Measured memory_bytes: 14164
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  cout << a/b << endl;
  cout << a%b << endl;
  printf("%.8lf\n", (double)a/(double)b);
  return 0;
}



Measured memory_bytes: 3220
n,m = map(int,input().split())
ts = [list(map(int,input().split()))[::-1] for j in range(m)]

ts.sort()

count = 0
t = 0

for j in range(m):
  if ts[j][1]>=t:
    count+=1
    t = ts[j][0]
    
print(count)

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

int main() {
  ll n,count=0;
  cin >> n;
  string s;
  cin >> s;
  int a[3][n];
  r(i,n){
    a[0][i]=0;
    a[1][i]=0;
    a[2][i]=0;
  }
  r(i,n){
    if(s[i]=='R')a[0][i]++;
    if(s[i]=='G')a[1][i]++;
    if(s[i]=='B')a[2][i]++;
    
    if(i){
      a[0][i]+=a[0][i-1];
      a[1][i]+=a[1][i-1];
      a[2][i]+=a[2][i-1];
    }
  }
  for(int i=0; i<n;i++){
    for(int j=i+1;j<n;j++){
      if(s[i]==s[j])continue;
      else{
        if(s[i]=='R'&&s[j]=='G'){
          count+=a[2][n-1]-a[2][j];
          if(j*2-i<n&&s[j*2-i]=='B')count--;
        }
        if(s[i]=='G'&&s[j]=='R'){
          count+=a[2][n-1]-a[2][j];
          if(j*2-i<n&&s[j*2-i]=='B')count--;
        }
        if(s[i]=='R'&&s[j]=='B'){
          count+=a[1][n-1]-a[1][j];
          if(j*2-i<n&&s[j*2-i]=='G')count--;
        }
        if(s[i]=='B'&&s[j]=='R'){
          count+=a[1][n-1]-a[1][j];
          if(j*2-i<n&&s[j*2-i]=='G')count--;
        }
        if(s[i]=='G'&&s[j]=='B'){
          count+=a[0][n-1]-a[0][j];
          if(j*2-i<n&&s[j*2-i]=='R')count--;
        }
        if(s[i]=='B'&&s[j]=='G'){
          count+=a[0][n-1]-a[0][j];
          if(j*2-i<n&&s[j*2-i]=='R')count--;
        }
      }
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3644
N=int(input())
blue=[input() for i in range(N)]
M=int(input())
red=[input() for i in range(M)]
line=[]
for i in range(N):
    if blue[i]==0:
        continue
    else:
        c=0
        for j in range(1,N-i):
            if blue[i]==blue[i+j]:
                blue[i+j]=0
                c+=1
        for k in range(M):
                if red[k]==blue[i]:
                    c-=1
        else:
            line.append(c+1)
print(max(line) if max(line)>0 else 0)

Measured memory_bytes: 3064
from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N, M = [int(i) for i in input().strip().split()]
    graph = [[] for _ in range(N)]
    sign = [0] * N
    for _ in range(M):
        a, b = [int(i) for i in input().strip().split()]
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)
    candidates = deque([0])
    visited = [False] * N
    visited[0] = True
    while len(candidates) > 0:
        v = candidates.popleft()
        for i in graph[v]:
            if visited[i]:
                continue
            visited[i] = True
            sign[i] = v
            candidates.append(i)
    print("Yes")
    for i in sign[1:]:
        print(i+1)

    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 35580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    ll n;
    string s;
    cin >> n >> s;

    vector<ll> freq(26, 0);
    rep(i, n) ++freq[s[i]-'a'];
    const ll MOD = 1000000007;

    ll res = 1LL;
    rep(i, 26){
        res = (res%MOD*(freq[i]+1)%MOD)%MOD;
    }

    cout << res-1 << endl;


    return 0;
}

Measured memory_bytes: 512
k = int(input())
cnt = 0
x = []
x.append(7)
if k == 7 or k == 1:
    print(1)
else:
    for i in range(1, k+2):
        x.append((10*x[i-1] + 7)%k)
        if x[i]%(k) == 0:
            print(i+1)
            break
        else:
            cnt += 1
            if cnt == k+1:
                print(-1)
                break

Measured memory_bytes: 48632
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

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

const ll INF = 1LL << 60;

ll N, W;
const ll V = 100100;
vector<ll> w, v;
// dp[i][sum_v]: 0~iの品物から価値の総和がsum_v以上となるように選んだ時の重さの総和の最小値
vector<vector<ll>> dp;

ll MIN(ll a, ll b)
{
  if (a < b)
  {
    return a;
  }
  else
  {
    return b;
  }
}

int main()
{
  ll i, sum_v;
  cin >> N >> W;
  w.resize(N);
  v.resize(N);
  rep(i, N)
  {
    cin >> w[i] >> v[i];
  }
  dp.assign(N, vector<ll>(V + 1, INF));

  // 初期化
  dp[0][0] = 0;
  for (sum_v = 1; sum_v <= v[0]; sum_v++)
  {
    dp[0][sum_v] = w[0];
  }

  for (i = 1; i < N; i++)
  {
    dp[i] = dp[i - 1];
    for (sum_v = v[i]; sum_v <= V; sum_v++)
    {
      if (dp[i - 1][sum_v - v[i]] == INF)
        continue;
      if (dp[i - 1][sum_v - v[i]] + w[i] <= dp[i][sum_v])
        dp[i][sum_v] = dp[i - 1][sum_v - v[i]] + w[i];
    }
  }

  ll ans = 0;
  for (sum_v = 0; sum_v <= V; sum_v++)
  {
    // cout << dp[N - 1][sum_v] << endl;
    if (dp[N - 1][sum_v] <= W)
    {
      ans = sum_v;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 79488
def run():
  N = int(input())
  A, B = map(int, input().split())
  
  if not B<N:
    for i in range(A, B+1):
      if i%N==0:
        print("OK")
        return
      else:
        pass
  print("NG")
  return
    
if __name__ == "__main__":
  run()

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A){
  if(A.size() == n+1){
    int now = 0;
    rep(i, q){
    	if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
  	return;
  }
  
  A.push_back(A.back());
  while(A.back() <= m){
  	dfs(A);
    A.back()++;
  }
}

int main(){
  	cin >> n >> m >> q;
  	a = b = c = d = vector<int> (q);
  	rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  
  	dfs(vector<int>(1, 1));
  
  	cout << ans << endl;
}

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

using namespace std;

int main()
{
    int N, M, X, Y, i, cache;
    vector<int> xa, ya;
    cin >> N >> M >> X >> Y;
    for(i = 0; i < N; ++i) {
        cin >> cache;
        xa.push_back(cache);
    }
    for(i = 0; i < M; ++i) {
        cin >> cache;
        ya.push_back(cache);
    }
    sort(xa.begin(), xa.end());
    sort(ya.begin(), ya.end());
    if(max(xa.back(), X) < min(ya.front(), Y)) {
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#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() {
    ll A, B, N;
    cin >> A >> B >> N;
    ll ans;
    if (N >= B) {
        ll x = B * ((N + 1) / B) - 1;
        ans = floor(A * x / B) - A * floor(x / B);
    } else {
        ans = floor(A * N / B) - A * floor(N / B);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include    <iostream>

using namespace std;

// A[x,y]、B[x,y]を通る直線とC[x,y]、D[x,y]を結ぶ線分の交差判定を返す。
// 「((ax - bx)*(cy - ay)+(ay - by)*(ax - cx))*((ax - bx)*(dy - ay)+(ay - by)*(ax - dx))」
bool cross(double* a, double* b, double* c, double* d) {
    return ((a[0]-b[0])*(c[1]-a[1])+(a[1]-b[1])*(a[0]-c[0]))*((a[0]-b[0])*(d[1]-a[1])+(a[1]-b[1])*(a[0]-d[0])) > 0.0;
}

int main() {
    // 四角形ABCDの対角線ACとBDの線分が交差するか否かで判定可能である。
    // 線分同士を直接比較するのは難しいため、片方を直線とみなした上で、
    // 「直線と線分の交差判定」をする事で可能となる。
    
    double pos[4][2];
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
        &pos[0][0], &pos[0][1], &pos[1][0], &pos[1][1], &pos[2][0], &pos[2][1], &pos[3][0], &pos[3][1])) {
        
        cout << (cross(pos[0],pos[1],pos[2],pos[3]) && cross(pos[2],pos[3],pos[0],pos[1]) ? "YES" : "NO") << endl;
    }

    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repn(i, n) for (ll i = 0; i <= (ll)(n); i++)
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);

class UnionFind
{
public:
	//以下公開

	//親の番号を格納する。親である場合は-(その集合のサイズ)
	vector<ll> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(ll N)
	{
		Parent = vector<ll>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	ll root(ll A)
	{
		if (Parent[A] < 0)
			return A;
		return Parent[A] = root(Parent[A]);
	} //代入しておくことで参照を速くする

	//自分のいるグループの頂点数を調べる
	ll size(ll A)
	{
		return -Parent[root(A)];
	} //親である場合は-(その集合のサイズ)なので、Ａの親の

	//AとBをくっ付ける
	bool connect(ll A, ll B)
	{
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B)
		{
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B))
			swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}

	bool same(ll A, ll B)
	{
		return root(A) == root(B);
	}
};

signed main()
{
	ll n, k, l,cnt=1;
	cin >> n >> k >> l;
	UnionFind UnionFind(n + 1), UF(n + 1);

	rep(i, k)
	{
		ll p, q;
		cin >> p >> q;
		UnionFind.connect(p, q);
	}

	rep(i, l)
	{
		ll r, s;
		cin >> r >> s;
		UF.connect(r, s);
	}

	vector<P> v;
	map<int,P> ma;
	map<P,int> ap;

	for (ll i = 1; i <= n; i++)
	{
		v.pb({UnionFind.root(i),UF.root(i)});
		ma[i]={UnionFind.root(i),UF.root(i)};
	}
	sort(all(v));

	for(int i=0;i < siz(v)-1;i++)
	{
		P next=v[i+1];
		if(next==v[i])cnt++;
		else{
			ap[v[i]]=cnt;
			cnt=1;
		} 
	}
	ap[v[siz(v)-1]]=cnt;

	for(int i=1;i <=n;i++)
	{
		cout<<ap[ma[i]]<<(i==n ? '\n' : ' ');
	}


}


Measured memory_bytes: 30828
def prime_table(n):
    rng = range(2, n + 1)
    tbl = [False] + [False] + [True for _ in rng]
    for i in rng:
        j = i + i
        if tbl[i]:
            while j < len(tbl):
                tbl[j] = False
                j += i
    ret = [i for i in range(n + 1) if tbl[i]]
    return ret

n = int(input())
d = 10 ** 9 + 7

ans = 1
for p in prime_table(n):
    power = 1
    buf = 0
    while True:
        p_cnt = n // (p ** power)
        if p_cnt == 0:
            break
        buf += p_cnt
        power += 1
    ans *= (buf + 1)
    if ans > d:
        ans %= d
print(ans)

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    long long x;
    cin >> x;
    long long ans = x / 500;
    ans *= 1000;
    ans += ((x % 500) / 5) * 5;
    cout << ans << '\n';
    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();
        int q = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long[] x = new long[q];
        for (int i = 0; i < q; i++) {
            x[i] = sc.nextLong();
        }

        long[] ans = new long[q];
        for (int i = 0; i < q; i++) {
            ans[i] = syakutori(a, x[i], n);
        }
        for (int i = 0; i < q; i++) {
            System.out.println(ans[i]);
        }
    }

    public static long syakutori(long[] a, long x, int n) {
        int right = 0;
        long res = 0;
        long sum = 0;
        for (int left = 0; left < n; left++) {
            while (right < n && sum + a[right] <= x) {
                // System.out.printf("left = %d,right = %d %n", left, right);
                // System.out.printf("a[%d] = %d %n", right, a[right]);
                sum += a[right];
                // System.out.printf("sum = %d %n", sum);
                right++;
            }
            // System.out.printf(" over left = %d,right = %d %n", left, right);
            res += Math.max(0, right - left);
            sum -= a[left];
        }
        return res;
    }
}



Measured memory_bytes: 69160
#include<iostream>

using namespace std;

int main() {
	int i, j, W, H;
	while (cin >> H >> W, H || W){
		for (i = 1; i <= H; i++){
			for (j = 1; j <= W; j++){
			    if(i % 2 == 1){
                                     if(j % 2 == 1)
                                         cout << "#";
                                     else
                                         cout << ".";
                                 }            
                                 if(i % 2 == 0){
                                     if(j % 2 == 1)
                                          cout << ".";
                                     else
                                          cout << "#";
                                 }  
			}
			cout << endl;
		}
          cout << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
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; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	double den = -1.0;
	P ans;
	for (int i = 0; i * a * 100 <= f; i++) {
		for (int j = 0; (i + a + j * b) * 100 <= f; j++) {
			if (i + j) {
				int water = (i * a + j * b) * 100;
				int maxsugar = min(f - water, e * water / 100);
				for (int k = 0; k * c <= maxsugar; k++) {
					int l = (maxsugar - k * c) / d;
					int sugar = k * c + l * d;
					if (chmax<double>(den, 100.0 * sugar / (sugar + water))) {
						ans = P(sugar + water, sugar);
					}
				}
			}
		}
	}
	cout << ans.first << " " << ans.second << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	afC := c - (a - b)
	if afC < 0 {
		fmt.Println(0)
	} else {
		fmt.Println(afC)
	}

}


Measured memory_bytes: 512
$stdin = DATA if $stdin.eof?

ARGF.each do |line|
  break if line =~ /-/
  kitty = line.chomp if line =~ /[a-zA-Z]/
  count = gets.to_i if line =~ /[a-zA-Z]/
  count.times do
    at = gets.to_i
    a = kitty[0..(at-1)]
    b = kitty[at..-1]
    kitty = b + a
  end
  puts kitty
end

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

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

    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans += (i*(1+(n/i))*(n/i))/2;
    }
    cout << ans << endl;
    return 0;
}


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

int main(int argc, char **argv)
{
	ll N, M;
	cin >> N >> M;
	vector<ll> A(N); for (ll i = 0; i < N; ++i) cin >> A[i];
	vector<pair<ll, ll>> P(M);
	for (ll i = 0; i < M; ++i)
	{
		ll b, c; cin >> b >> c;
		P[i] = pair<ll, ll>(b, c);
	}

	sort(A.begin(), A.end());
	sort(P.begin(), P.end(), [](auto &a, auto &b)
							 {
								 return a.second > b.second;
							 });


	ll sum{0};
	ll K{0};
	for (auto &p : P)
	{
		for (ll i = 0; i < p.first && K < N; ++i, ++K)
		{
			sum += max(A[K], p.second);
		}
	}

	for (; K < N; ++K)
		sum += A[K];
	std::cout << sum << std::endl;
}


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

typedef long long ll;

int N, M, S, T;

int shortest_path(vector<vector<int>> G){
    vector<int> d(N, -1);
    
    queue<int> que;
    que.push(S);
    d[S] = 0;
    
    while(!que.empty()){
        auto u = que.front(); que.pop();
        for(auto v: G[u]){
            if(d[v] == -1){
                d[v] = d[u] + 1;
                if(v == T)
                    return d[v];
                que.push(v);
            }
        }
    }
    return -1;
}


vector<ll> bfs(vector<vector<int>> G, int s){
    vector<int> d(N, -1);
    
    queue<int> que;
    que.push(s);
    d[s] = 0;
    
    while(!que.empty()){
        auto u = que.front(); que.pop();
        for(auto v: G[u]){
            if(d[v] == -1){
                d[v] = d[u] + 1;
                que.push(v);
            }
        }
    }
    
    vector<ll> res(N);
    for(int i=0; i<N; i++) if(d[i] >= 0)
        res[d[i]]++;
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> M >> S >> T; S--; T--;
    
    vector<vector<int>> G(N);
    for(int i=0; i<M; i++){
        int x, y; cin >> x >> y; x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    
    int sp = shortest_path(G);
    auto st = bfs(G, S);
    auto tt = bfs(G, T);
    
    ll ans = 0;
    for(int i=0; i<=sp-2; i++)
        ans += st[i] * tt[sp-2-i];
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17492
from copy import copy
n, *x = map(int, open(0).read().split())
a = []
for i, v in enumerate(x):
    a.append((v, i))
a.sort()

# a[(i - 1)/ /2] , a[i // 2]
ans = [0] * n
for i in range(n):
    if i <= (n - 1) // 2:
        ans[a[i][1]] = a[n // 2][0]
    else:
        ans[a[i][1]] = a[(n - 1) // 2][0]
for y in ans:
    print(y)


Measured memory_bytes: 39696
#include<stdio.h>

int main(){
	int N,i;
	scanf("%d",&N);
	int a[N];
	int two=0,four=0;
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
		if(a[i]%2==0){
			if(a[i]%4==0)four++;
			else two++;
		}
	}
	
	if(two>=2)N-=two;
	else N--;
	if((four>=(N+1)/2))printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  vector<int64_t> L(87);
  L.at(0) = 2;
  L.at(1) = 1;
  for(int i = 2; i <= N; i++){
    L.at(i) = L.at(i-1) + L.at(i-2);
  }

  cout << L.at(N) << endl;    
}


Measured memory_bytes: 3576