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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,d;
    cin>>n>>d;
    ll res=0;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000
#define INF 1000000000000000000ll
const int N = 1e6;
const int mod = 1e9+7;

map<string,int>m;
string s, t;
int a, b;
int main() {
    cin >> t;
    for(int i = 0; i < t.size();++i)
        s+='x';
    cout << s;
    return 0;
}


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

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


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
int a[999999];
int  main() 
{
	int n,f=1;
	scanf("%d",&n);
	if(n==0)
		puts("0");
	else
	{
		while(n)
		{
			if(n%2!=0)
			{
				a[f]=1;
				f++;
				n=(n-1)/(-2);
			}
			else
			{
				a[f]=0;
				f++;
				n/=(-2);
			}
		}
		for(int i=f-1;i>=1;i--)
			printf("%d",a[i]); 
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class a{
    public static void Main(){
        var num = Console.ReadLine().Split(' ').Select(s => double.Parse(s)).ToArray();
        string ans = "No";
        if(num[0]/num[1] <= num[2]){
            ans = "Yes";
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 19156
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if(a == b + c || b == a + c || c == a + b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		scan.close();
	}

}


Measured memory_bytes: 23508
#include<stdio.h>
#include<stdlib.h>


int main(){
  int n,i;
  int *A;
  int *B;
  int c[10001];

  for(i=0;i<10001;i++)
    c[i]=0;

  scanf("%d",&n);
  A = malloc(sizeof(int)*n);
  B = malloc(sizeof(int)*n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    c[A[i]]++;
  }

  for(i=1;i<10001;i++)
    c[i] = c[i]+c[i-1];

  for(i=n-1;i>=0;i--){
    B[c[A[i]]-1] = A[i];
    c[A[i]]--;
  }

  for(i=0;i<n-1;i++)
    printf("%d ",B[i]);

  printf("%d\n",B[n-1]);

  return 0;
}

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

int main()
{
    int n; std::cin >> n;
    bool res = false;
    for(int i = 0; i < 30; i++){
        for(int j = 0; j < 30; j++){
            if(i * 4 + j * 7 == n)res = true;
        }
    }
    std::cout << (res ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int n;
ll a[100010];

ll calc(bool state) {
  ll cur = 0;
  ll ret = 0;
  rep(i,n) {
    cur += a[i];
    if( state ) { // +
      if( cur == 0 ) {
	++cur;
	++ret;
      } else if( cur < 0LL ) {
	ret += (llabs(cur)+1LL);
	cur += (llabs(cur)+1LL);
      }
    } else { // -
      if( cur == 0 ) {
	--cur;
	++ret;
      } else if( cur > 0LL ) {
	ret += (llabs(cur)+1LL);
	cur -= (llabs(cur)+1LL);
      }
    }
    state = !state;
  }
  return ret;
}

void compute() {
  ll ans = LLONG_MAX;
  rep(i,2) ans = min(ans,calc(i));
  cout << ans << endl;
}

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  compute();
  return 0;
}

/*
  -1 4 3 2 -5 4

  -1 4 3  2 -5 4
  -  + -  + -  +
  -1 3 -1 1 -4 1 
      (7)     (1)
  

*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int X,A,B;
    cin >> X >> A >> B;
    X -= A;
    while(X >= B){
        X -= B;
    }
    cout << X <<"\n";
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S,T;
int A,B;

int palin(string SS) {
	int i;
	FOR(i,SS.size()) if(SS[i]!=SS[SS.size()-1-i]) return 0;
	return 1;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	vector<int> V;
	
	cin>>S;
	V.push_back(0);
	FORR(c,S) {
		if(c=='x') {
			V.back()++;
		}
		if(c!='x') {
			T+=c;
			V.push_back(0);
		}
	}
	A=S.size();
	B=T.size();
	
	if(!palin(T)) return _P("-1\n");
	int ret=0;
	FOR(i,V.size()/2) ret+=abs(V[i]-V[V.size()-1-i]);
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

long long N, X, A[200009], B[200009], minx = (1LL << 60);

long long ranges(int l, int r) {
	return B[r] - B[l - 1];
}

int main() {
	cin >> N >> X;
	for (int i = 1; i <= N; i++) { cin >> A[i]; B[i] = A[i]; }
	for (int i = 1; i <= N; i++) B[i] += B[i - 1];

	for (int i = 1; i <= N; i++) {
		long long sum = 0, cx = N, ret = 3;
		while (cx >= 1) {
			long long L = cx - i + 1, R = cx; L = max(L, 1LL);
			sum += ranges(L, R)*max(5LL, ret); ret += 2; if (sum >= (1LL << 60)) sum = (1LL << 60);
			cx = L - 1;
		}
		minx = min(minx, sum + 1LL * (N + i) * X);
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 3328
import math
n, d = map(int, input().split())

x =[]

for i in range(n):
    x.append(list(map(int, input().split())))

def kyori(x,y):
    kyo2=0
    for i in range(d):
        kyo2 += (x[i]-y[i])**2
    #print(kyo2)
    return math.sqrt(kyo2)

#dis= kyori(x[0],x[1])
#print(x)
#print(dis)

count=0

for i in range(n):
    for j in range(n):
        if i==j:
            pass
        else:
            dis = kyori(x[i], x[j])
            #print(dis**2)
            #print(dis)
            if dis.is_integer():
                count += 1
print(int(count/2))

Measured memory_bytes: 3064
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.parse();
    let v: Vec<i64> = (0..n).map(|_| iter.parse()).collect();
    let c = v.iter().filter(|&x| *x < 0_i64).count();
    let sum: i64 = v.iter().map(|x| x.abs()).sum();
    let min: i64 = v.iter().map(|x| x.abs()).min().unwrap();

    println!("{}", if c % 2 == 0 { sum } else { sum - 2 * min });
}

Measured memory_bytes: 6396
//ihdignite

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

const int MAXN = 1001, di[4]={1, 0, -1, 0}, dj[4]={0, 1, 0, -1};

int h, w, d[MAXN][MAXN], ans;
string a[MAXN];
queue<pii> qu;

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

	cin >> h >> w;
	memset(d, 0x3f, sizeof(d));
	for(int i = 0; i < h; i++) {
		cin >> a[i];
		for(int j = 0; j < w; j++) {
			if(a[i][j] == '#') {
				qu.push(pii(i, j));
				d[i][j]=0;
			}
		}
	}

	while(!qu.empty()) {
		pii u = qu.front();
		qu.pop();
		ans = max(ans, d[u.first][u.second]);
		for(int k = 0; k < 4; ++k) {
			int ni = u.first+di[k], nj = u.second+dj[k];
			if(ni>=0&&ni<h&&nj>=0&&nj<w&&d[ni][nj]>1e9) {
				d[ni][nj] = d[u.first][u.second]+1;
				qu.push(pii(ni, nj));
			}
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 13456
#!/usr/bin/env ruby

n = gets.to_i
line1 = gets.split.map {|num| num.to_i }
line2 = gets.split.map {|num| num.to_i }

(0..n-1).reverse_each do |i|
  line2[i] += line2[i+1].to_i

  left = line1[i+1].to_i
  down = line2[i]
  line1[i] += (left > down)? left : down
end

puts line1[0]


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
 using namespace std;
 int a[4][4],flag[4][4];
 int main()
 {
 	for(int i=1;i<=3;i++)
 		for(int j=1;j<=3;j++)
 			cin>>a[i][j];
 	int n,ans=0,x;
 	cin>>n;
 	while(n--){
 		cin>>x;
 		for(int i=1;i<=3;i++){
 			for(int j=1;j<=3;j++)
 				if(a[i][j]==x) flag[i][j]=1;
		 }
	 }
	for(int i=1;i<=3;i++){
		int cnt=0;
 		for(int j=1;j<=3;j++)
 			if(flag[i][j]) cnt++;
 		if(cnt==3){
 			cout<<"Yes"<<endl;
 			return 0;
		 }
	}
	for(int i=1;i<=3;i++){
		int cnt=0;
 		for(int j=1;j<=3;j++)
 			if(flag[j][i]) cnt++;
 		if(cnt==3){
 			cout<<"Yes"<<endl;
 			return 0;
		 }
	}
	if(flag[1][1]+flag[2][2]+flag[3][3]==3||flag[1][3]+flag[2][2]+flag[3][1]==3){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
 }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int H,W;
   while(cin >> H >> W)
   if(1<=H&&W<=300){
   for(int j=0; j<H; j++){
       for(int i=0; i<W; i++){
           if((i+j)%2==0)
           cout << '#';
           else
           cout << '.';
}
           cout << endl;
}
    cout << endl;
}
}


Measured memory_bytes: 3076
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e18) + 1;
const int mod = 479001599;
const int maxn = 5e5 + 111;
        
using namespace std;          

int n, a[maxn];

void solve(){                 
	cin >> n;

	int x = 1, ans = 0, k = n;

	for (int i = 1; i <= n; i++){
		cin >> a[i];
		if (a[i] == x){
			x++;
			if (i == x)
				k--;
			else
				ans++;
		}
	}

	if (x == 1)
		cout << -1;
	else
		cout << k - ans;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 1792
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n = parseInt(input[0], 10);
    var s = input[1].split('');

    var rightCharCount = {};
    var leftCharCount = {};

    for (var i = 0; i < n; i++) {

        if (s[i] in rightCharCount) {
            rightCharCount[s[i]]++;
        }
        else {
            rightCharCount[s[i]] = 1;
            leftCharCount[s[i]] = 0;
        }
    }

    var both = 0;
    var ans = 0;

    for (var i = 0; i < n; i++) {

        leftCharCount[s[i]]++;
        if (leftCharCount[s[i]] === 1) {
            both++;
        }

        rightCharCount[s[i]]--;
        if (rightCharCount[s[i]] === 0) {
            both--;
        }

        ans = Math.max(ans, both);
    }

    console.log(ans);

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

using P = pair<int, int>;

int n, q;
vi32 a;

inline P calc_diff(int x, int d) {
  int l = lower_bound(all(a), x - d) - a.begin();
  int r = upper_bound(all(a), x + d) - a.begin();
  return P(l, r);
}

void solve() {
  cin >> n >> q;
  a.resize(n);
  cin >> a;
  vi64 sums(n + 1);
  rep(i, n) {
    sums[i + 1] += sums[i] + a[i];
  }
  vector<vi64> step(2, vi64(n + 1));
  rep(i, 2) rep(j, n) {
    if (j % 2 == i) step[i][j + 1] = a[j];
    step[i][j + 1] += step[i][j];
  }
  rep(qi, q) {
    int x;
    cin >> x;
    int ok = 1e9 + 1, ng = -1;
    while (abs(ok - ng) > 1) {
      int diff = (ok + ng) / 2;
      auto p = calc_diff(x, diff);
      int l = p.first;
      int r = p.first + (n - l) / 2;
      (r <= p.second ? ok : ng) = diff;
    }
    auto p = calc_diff(x, ok);
    int L = p.first;
    int R = L + (n - L) / 2;
    int C = n - L;
    i64 ans = step[C % 2 == L % 2][L] + sums[n] - sums[R];
    cout << ans << endl;
  }
}

Measured memory_bytes: 4464
let inf = 101010101010101010
let _ = Scanf.scanf "%d" @@ fun n ->
  let a = Array.init (n+1) (fun i ->
    if i = 0 then (0, inf) else Scanf.scanf " %d %d" (fun x y -> -x, y)) in
  Array.sort compare a;
  Array.fold_left (fun (s, (x',y')) (x,y) ->
    s + min (x-x') (y-y'), (x,y)) (snd a.(0), a.(0)) a
  |> fst |> Printf.printf "%d\n"

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

int main(){

    int n;
    int a, b;
    cin>>n>>a>>b;
    int p1=0, p2=0,p3=0;
    for(int i=0;i<n;i++){
        int p;
        cin>>p;
        if(p<=a)p1++;
        else if(b<p)p3++;
        else p2++;
    }
    cout<<min(min(p1, p2), p3)<<endl;


    return 0;
}

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

int cnt[1000005];

long long int power(long long int a,long long int b)
{
	long long int ans=1;
	for(int i=0;i<b;i++)
	{
		ans=ans*a;
	}
	return ans;
}

int main() 
{
	long long int n,p;
	long long int tmp;
	
	cin>>n>>p;
	
	tmp=p;
	
	if(n==1)
	{
		cout<<p<<endl;
		return 0;
	}
	
	for(long long int i=2;i*i<=tmp;i++)
	{
		cnt[i]=0;
		// cout<<p<<endl;
		while(p%i==0)
		{
			cnt[i]++;
			p=p/i;
		}
	}
	
	// cout<<cnt[103]<<endl;
	
	long long int ans=1;
	
	for(long long int i=2;i*i<=tmp;i++)
	{
		if(cnt[i]/n)
		{
			// cout<<"here "<<i<<endl;
			long long int val=cnt[i]/n;
			ans=ans*power(i,val);
			// cout<<ans<<endl;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

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

vector<vector<int>> G;
vector<int> color;

bool dfs(int v, int cur = 0) {
  color[v] = cur;
  for (auto next : G[v]) {
    if(color[next] != -1) {
      if(color[next] == cur) return false;
      continue;;
    }
    if(!dfs(next, !cur)) return false;
  }
  return true;
}

const int INF = 1e9;

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

  G.resize(n);
  color.resize(n, -1);
  vector<vector<char>> s(n, vector<char>(n));
  vector<vector<int>> dist(n, vector<int> (n, INF));
  rep(i,n) rep(j,n) {
    cin >> s[i][j];
    if(s[i][j] == '1') {
      dist[i][j] = 1;
      dist[j][i] = 1;
      G[i].push_back(j);
      G[j].push_back(i);
    }
  }

  if(!dfs(0)) {
    cout << -1 << '\n';
    return 0;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if(i == j) continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int answer = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if(INF <= dist[i][j]) continue;
      answer = max(answer, dist[i][j]);
    }
  }

  cout << answer + 1 << endl;

}



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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX1005

int n , k;
string s;;

int main()
{
    _FastIO;
    cin >> n >> k;
    cin >> s;
    s[k - 1] = char(int(s[k - 1]) + 32);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = (int(i) for i in input().split());

num = [-1 for i in range(n)];

for i in range(m):
    s, c = (int(i) for i in input().split());
    s -= 1;
    if num[s] > -1 and num[s] != c:
        print('-1');
        exit(0);
    num[s] = c;

if n == 1 and num[0] <= 0:
    print(max(num[0], 0));
    exit(0);

if num[0] == 0:
    print('-1');
    exit(0);

for i in range(n):
    print(max(num[i], int(i == 0)), end="");


Measured memory_bytes: 3064
S = input()
if S[0] == 'A' and 'C' in S[2:-1]:
    idx = S.index('C')
    if all(c.islower() or i in (0, idx) for i, c in enumerate(S)):
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 9044
#include <iostream>
using namespace std;
int A,B,C;
int main(){
  cin >> A >> B >> C;
  int sum = 0;
  for(int i=0;i<B;i++){
    sum += A;
    if(sum%B==C){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S = [list(map(str, input().split())) for _ in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j] == "snuke":
      print("{}{}".format(alpha[j], i+1))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0)

// *start on @date: 2020-05-10 20:27

struct node
{
    ll c;
    ll a[15];
} s[15];
ll vis[15], ans[15];
ll n, m, x;
struct node2
{
    ll num;
    ll ans[15];
    ll vis[15];
    ll cnt;
};
bool check(node2 top)
{
    for (ll i = 0; i < m; i++)
    {
        if (top.ans[i] < x)
            return false;
    }
    return true;
}
ll minn = 999999999;
void bfs()
{
    queue<node2> q;
    node2 ss;
    ss.num = 0, ss.cnt = 0;
    for (ll i = 0; i < n; i++)
    {
        ss.ans[i] = 0;
        ss.vis[i] = 0;
    }

    q.push(ss);
    node2 top;

    while (!q.empty())
    {
        top = q.front();
        if (check(top))
        {
            minn = min(minn, top.num);
        }
        q.pop();
        for (ll i = top.cnt; i < n; i++)
        {
            if (!top.vis[i])
            {
                node2 temp;
                for (ll j = 0; j < n; j++)
                    temp.vis[j] = top.vis[j];
                temp.vis[i] = 1;
                temp.num = top.num + s[i].c;
                for (ll j = 0; j < m; j++)
                    temp.ans[j] = top.ans[j] + s[i].a[j];
                temp.cnt = i;
                q.push(temp);
            }
        }
    }
}

int main()
{
    IOS;
    cin >> n >> m >> x;
    for (ll i = 0; i < n; i++)
    {
        cin >> s[i].c;
        for (ll j = 0; j < m; j++)
            cin >> s[i].a[j];
    }
    bfs();
    if (minn != 999999999)
        cout << minn;
    else
        cout << -1;
    return 0;
}

Measured memory_bytes: 3888
#include <iostream>
using std::cin;
using std::cout;

#define _for(i, j, k) for(int i = j; i <= k; i++)

int arr[4][3][10];

int main() {
	int n, v, r, f, b;
	cin >> n;
	while(n--) {
		cin >> b >> f >> r >> v;
		arr[b - 1][f - 1][r - 1] += v;
	}
	bool fst = 1;
	_for(i, 0, 3) {
		if(fst) fst = 0;
		else cout << "####################\n";
		_for(j, 0, 2) {
			_for(k, 0, 9) {
				cout << ' ' << arr[i][j][k];
			}
			cout << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderTemplate {
    class Program {
        static void Main (string[] args) {
            var NM = ReadInts ();
            var N = NM[0];
            var M = NM[1];
            var X = ReadInts ().OrderBy (x => x).ToList ();
            var diffsAndI = Enumerable.Range (1, M - 1).Select (i => new int[2] { X[i] - X[i - 1], i - 1 }).ToList ();
            var diffs = diffsAndI.Select (x => x[0]).ToList ();
            var maxIndexs = diffsAndI.OrderByDescending (x => x[0]).Select (x => x[1]).ToList ();
            foreach (var k in Enumerable.Range (0, Math.Min (N, M) - 1)) {
                diffs[maxIndexs[k]] = 0;
            }
            Console.WriteLine (diffs.Sum ());
        }
        /* Input & Output*/
        static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }
        static List<int> ReadInts () {
            return Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
        }
        static List<List<int>> ReadColumns (int n) {
            /*
            入力例
            A1 B1
            A2 B2
            ...
            An Bn

            出力例
            [[A1,A2,...,An], [B1,B2,...,Bn]]
            */
            var seq = Enumerable.Range (0, n).Select (i => ReadInts ()).ToList ();
            return Enumerable.Range (0, seq.First ().Count ()).Select (i => seq.Select (items => items[i]).ToList ()).ToList ();
        }
        static void PrintEnum<T> (IEnumerable<T> list) {
            Console.Write (list.First ());
            foreach (var item in list.Skip (1)) {
                Console.Write ($" {item}");
            }
            Console.Write ("\n");
        }
        static void PrintLnEnum<T> (IEnumerable<T> list) {
            foreach (var item in list) {
                Console.WriteLine (item);
            }
        }

        /* Numeric Function */
        static int Fact (int n) {
            return Enumerable.Range (1, n).Aggregate (1, ((i, k) => i * k));
        }
        static int PermNum (int n, int m) {
            if (m > n) {
                return 0;
            }
            return Enumerable.Range (n - m, m + 1).Aggregate (1, ((i, k) => i * k));
        }
        static int CombNum (int n, int m) {
            return PermNum (n, m) / Fact (m);
        }
        // 最大公約数 (m ≧ n)
        static int GCD (int m, int n) {
            if (n == 0) {
                return m;
            } else {
                return GCD (n, m % n);
            }
        }
        // 最小公倍数 (m ≧ n)
        static int LCM (int m, int n) {
            return GCD (m, n) / (m * n);
        }

    }
}

Measured memory_bytes: 36956
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair

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

    int n ; cin>>n;

    set<int> hon({2, 4, 5, 7,  9});
    set<int> pon({0, 1, 6 , 8});
    set<int> bon({3});

    int p = n%10;
    if (hon.count(p)) cout<<"hon";
    else if (pon.count(p)) cout<<"pon";
    else cout<<"bon";

}


Measured memory_bytes: 3656
#include<stdio.h>
#include<vector>
using namespace std;

const int n=100010;

vector<int> graph[n];
int dep[n],p[20][n];

void go(int now) {
	for (int i=0;i< graph[now].size();i++){
		dep[graph[now][i]]=dep[now]+1;
		p[0][graph[now][i]]=now;
		go(graph[now][i]);
	}
	return;
}

int LCA(int l,int r){
	if(dep[l]<dep[r])swap(l,r);
	for(int i=19;i>=0;i--){
		if(dep[p[i][l]]>=dep[r]){
			l=p[i][l];
		}
	}
	 for(int i=19;i>=0;i--){
	 	if(p[i][l]!=p[i][r]){
	 		l=p[i][l];
	 		r=p[i][r];
		 }	
	 }
	if(l!=r)return p[0][l];
	else return l;
	}
	
int main(){
	int n,k,temp,q,l,r;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&k);
		graph[i].resize(k);
		for(int j=0;j<k;j++){
		scanf("%d",&graph[i][j]);
		}
	}
	go(0);
	for(int i=1;i<20;i++){
		for(int j=0;j<n;j++){
			p[i][j]=p[i-1][p[i-1][j]];
		}
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
	scanf("%d%d",&l,&r);
	printf("%d\n",LCA(l,r));
	}
}


Measured memory_bytes: 20928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s;
		s = sc.next();
		
		sc.close();
		
		int n = s.length();
		int count = 0;
		long ans = 0;
		int p[];
		p = new int[n];
		
		for(int i = n - 1; i >= 0; --i) {
			if(s.charAt(i) == 'B') 
				p[count++] = i + 1;
		}
		
		if(count < n && count > 0) {
			for(int i = 0; i < n; ++i) {
				if(p[i] == 0)break;
				ans += n - p[i] - i;
			}
		}
		
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 25904
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

const string YES = "Odd";
const string NO = "Even";

void solve(ll a, ll b) { cout << (a * b % 2 ? YES : NO) << endl; }

int main() {
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  solve(a, b);
  return 0;
}


Measured memory_bytes: 256
# ABC160c


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    b = []
    for i in a:
        b.append(i - k)
    b.extend(a)
    ans = 10 ** 12
    # print(b)
    for i in range(n):
        #print(i, b[i+n-1], b[i])
        ans = min(ans, b[i+n-1]-b[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	class DisjointSet {
		
		int[] p, r, w;
		
		public DisjointSet(int size) {
			p = new int[size];
			r = new int[size];
			w = new int[size];
			for (int i = 0; i < size; i++) makeSet(i);
		}

		private void makeSet(int x) {
			p[x] = x;
			r[x] = w[x] = 0;
		}
		
		private int findSet(int x) {
			if (p[x] != x) {
				int tmp = findSet(p[x]);
				w[x] += w[p[x]];
				p[x] = tmp;
			}
			return p[x];
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}
		
		public void unite(int x, int y, int z) {
			link(findSet(x), findSet(y), z - w[x] + w[y]);
		}

		private void link(int x, int y, int cost) {
			if (r[x] > r[y]) {
				p[y] = x;
				w[y] -= cost;
			} else {
				p[x] = y;
				w[x] += cost;
				if (r[x] == r[y]) {
					r[y]++;
				}
			}
		}
		
		public int sum(int x) {
			int sum = 0;
			int cur = x;
			while (cur != p[cur]) {
				sum += w[cur];
				cur = p[cur];
			}
			return sum;
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y, 0);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 60012
import collections
n,k = map(int,input().split())
a = list(map(int,input().split()))
list = [1]
i = 0
num = a[0]
for i in range(3*n):
    list.append(num)
    num = a[num-1]

cnt = collections.Counter(list)
onevalue = [k for k,v in cnt.items() if v == 1]
lstart = len(onevalue)
lroop = len(set(list))-lstart

if k <= lstart:
    num = a[0]
    for i in range(k-1):
        num = a[num-1]
    print(num)
    exit()
elif lstart == 0:
    k = (k-lstart)%lroop
    num = 1
    for i in range(k):
        num = a[num-1]
    print(num)
    exit()
else:
    k = (k-lstart)%lroop
    num = a[0]
    if lstart > 0:
        for i in range(lstart-1):
            num = a[num-1]
    for i in range(k):
        num = a[num-1]
    print(num)
    exit()

Measured memory_bytes: 50948
#include<bits/stdc++.h>
 
using namespace std;
 
 
int main(){
	
  string s;cin >> s;
  int rem = 15 - s.size();
  int won = 0;
  for(auto x:s){
  	if(x == 'o') ++won;
  }
  if(won + rem >= 8) cout << "YES";
  else cout << "NO";
}

Measured memory_bytes: 256
def solve(n, m, a, b):
    D = {(i+1): 0 for i in range(n)}
    for v in a + b:
        D[v] += 1
    ok = len(list(
        filter(lambda num: num % 2 == 0, D.values())
    )) == n
    return "YES" if ok else "NO"

n, m = map(int, input().split())
ab = [map(int, input().split()) for i in range(m)]
a, b = zip(*ab)
print(solve(n, m, a, b))

Measured memory_bytes: 71808
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u64,
    }
    println!("{}", (1..n+1).sum::<u64>());
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
l = [[] for _ in range(m)]
 
for i in range(n):
  a, b = map(int, input().split())
  if a <= m:
    l[a-1].append(b)

import heapq
a = []
ans = 0
heapq.heapify(a)
for i in range(m):
  for j in range(len(l[i])):
    heapq.heappush(a, (-1)*l[i][j])
  if len(a) != 0:
    ans += heapq.heappop(a)*(-1)
print(ans)

Measured memory_bytes: 73248
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#define io ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=1e3+10;
char s[N][N];
int d[N][N];
struct node{
    int x,y,d;
};
int n,m,sx,sy,ex,ey;
bool check(int i,int j){
    return i>=1&&i<=n&&j>=1&&j<=m;
}
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
void solve(){
    //cin>>n>>m>>sx>>sy>>ex>>ey;
    scanf("%d%d%d%d%d%d",&n,&m,&sx,&sy,&ex,&ey);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    deque<node> q;
    memset(d,inf,sizeof(d));
    q.push_front(node{sx,sy,0});
    d[sx][sy]=0;
    while(q.size()){
        node p=q.front();q.pop_front();
        if(p.x==ex&&p.y==ey){
           break;
        }
        for(int k=0;k<4;k++){
            int x=p.x+dx[k],y=p.y+dy[k];
            if(!check(x,y))continue;
            if(s[x][y]=='#')continue;
            if(d[x][y]>d[p.x][p.y]){
                q.push_front(node{x,y,p.d});
                d[x][y]=d[p.x][p.y];
            }
        }
        for(int i=0;i<5;i++) {
			for(int j=0;j<5;j++) {
				int ny = p.y - 2 + j, nx = p.x - 2 + i;
				if (!check(nx,ny)) continue;
				if (s[nx][ny] == '#') continue;
				if (d[nx][ny] > d[p.x][p.y] + 1) {
					d[nx][ny] = d[p.x][p.y] + 1;
					q.push_back(node{ nx, ny,0 });
				}
			}
		}
    }
    if(d[ex][ey]==inf)cout<<-1;
    else cout<<d[ex][ey];
}
int main(){
    //io;
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 8344
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, A[201010], B[201010];
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
	vector<int> ord;
	rep(i, 0, N) ord.push_back(i);
	sort(all(ord), [&](int a, int b) { return B[a] < B[b]; });

	int t = 0;
	rep(i, 0, N) {
		int a = A[ord[i]];
		int b = B[ord[i]];

		t += a;
		if (b < t) return no;
	}

	return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i] >> B[i];

	cout << solve() << endl;
}







Measured memory_bytes: 2936
_s = input()
cnt = 0
# if(_s[0] == 'R'):
# 	cnt += 1
first = None
for i in range(len(_s)):
	if(_s[i] == 'R'):
		if first is not None:
			if(_s[i] == _s[i-1]):
				cnt += 1
		if first is None:
			cnt += 1
			first = True
print(cnt)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define size 5005
const long MOD = 1e9+7;
pair<int,int>pos[size];
signed main()
{
    long test;
    test=1;
    // cin>>test;
    while(test--){
    long i,j,s,n,x,k,ans,most,index,c,maxi=0,temp,aw,bw,w,count,sum;
    cin>>s>>c;
    if(2*s<=c)
    {
        c=c-2*s;
        c/=4;
        cout<<s+c;
    }
    else
    {
        c/=2;
        cout<<c;
    }
        
    }
}

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

int main()
{
	int a, b, c, answer;
	bool can = false;

	cin >> a >> b >> c;
		

	for (int i = 1; i <= b; i++) {
	
		if (i * a % b == c) {
			can = true;
			break;
		}
	}


	if (can) { cout << "YES" << endl; }
	else     { cout << "NO"  << endl; }
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n, sm = 0;
  cin >> n;
  if(n >= 500){
    sm += n / 500 * 1000;
    n = n % 500;
  }
  if(n >= 5){
    sm += n / 5 * 5;
  }
  
  cout << sm << "\n";
}

Measured memory_bytes: 3624
N = int(input())
B = list(map(int, input().split()))

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N-1:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
else:
  while count <= N-2:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
  one.append(max(B))
  B.remove(max(B))

print(sum(one)-sum(two))

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

int q;
string a, b;
vector<vector<int>> dp(1010, vector<int>(1010, 0));

int main(void){
    
    cin >> a >> b;
    a.insert(a.begin(), ' '), b.insert(b.begin(), ' ');
    
    for(int i = 0; i <= a.size(); ++i) dp[i][0] = i;
    for(int i = 0; i <= b.size(); ++i) dp[0][i] = i;
    
    for(int i = 1; i <= a.size(); ++i){
        for(int j = 1; j <= b.size(); ++j){
            dp[i][j] = min({dp[i - 1][j - 1] + (a[i - 1] == b[j - 1] ? 0 : 1), dp[i - 1][j] + 1, dp[i][j - 1] + 1});
        }
    }
    cout << dp[a.size()][b.size()] << endl;
    
    return 0;
}



Measured memory_bytes: 6684
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#define pb push_back
using namespace std;
typedef long long int lli;

vector<vector<int> >g;
vector<int> path;
int vis[111111];
int iro[111111];
int dfs2(int k,int end){
  if(iro[k]==2) return 0;
  vis[k]=1;
  int i,tmp;
  tmp=1;
  for(i=0;i<g[k].size();i++){
    if(vis[g[k][i]]==1) continue;
    tmp+=dfs2(g[k][i],end);
  }
  return tmp;
}

int dfs3(int k,int end){
  if(iro[k]==1) return 0;
  vis[k]=1;
  int i,tmp;
  tmp=1;
  for(i=0;i<g[k].size();i++){
    if(vis[g[k][i]]==1) continue;
    tmp+=dfs3(g[k][i],end);
  }
  return tmp;
}


bool dfs(int k,int end){
  
  if(k==end) {
    path.pb(k);
    return true;
  }
  vis[k]=1;
  int i;
  bool flag;
  
  for(i=0;i<g[k].size();i++){
    if(vis[g[k][i]]==1) continue;
    flag=dfs(g[k][i],end);
    if(flag){
      path.pb(k);
      return true;
    }
  }
  return false;
}


int main(void){
  
  g.clear();
  int n,i,a,b;
  cin>>n;
  for(i=0;i<=n;i++){
    vector<int> v;
    g.pb(v);
  }
  for(i=0;i<n-1;i++){
    cin>>a>>b;
    g[a].pb(b);
    g[b].pb(a);
  }
  int f,s;
  memset(vis,0,sizeof(vis));
  path.clear();
  dfs(n,1);
  
  memset(iro,0,sizeof(iro));
  for(i=0;i<(path.size()+1)/2;i++){
    iro[path[i]]=1;
  }
  for(i=0;i<(path.size())/2;i++){
    iro[path[path.size()-1-i]]=2;
  }

  
  memset(vis,0,sizeof(vis));
  f=dfs2(1,n);
  memset(vis,0,sizeof(vis));
  s=dfs3(n,1);
 
  
  if(f>s) cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
  return 0;
}

Measured memory_bytes: 12144
#include <stdio.h>

int main(void){

   int loan=100000;
   double temp=0.0;
   int week;
   int check=0;
   
   scanf("%d", &week);
   
   while(week > 0){
   
      temp=loan*1.05;
      loan=(int)temp;
      
      check = loan % 1000;
      if(check!=0){
         loan/=1000;
         loan*=1000;
         loan+=1000;
         week--;
         continue;
      }
      
      check = loan % 100;
      if(check!=0){
         loan/=100;
         loan*=100;
         loan+=100;
         week--;
         continue;
      }
      
      check = loan % 10;
      if(check!=0){
         loan/=10;
         loan*=10;
         loan+=10;
         week--;
         continue;
      }
      
      if( (temp-loan) != 0){
         loan+=1;
      }
      week--;
   }
   printf("%d\n",loan);
   return 0;
}

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

using namespace std;

typedef long long ll;

template<typename T>
void _dump(const char* s, T&& head)
{
  cerr << s << "=" << head << endl;
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail)
{
  while (*s != ',')
    cerr << *s++;
  cerr << "=" << head << ",";
  _dump(s + 1, tail...);
}

template<typename T>
void _dumpv(const char* s, T&& v)
{
  cerr << *s << "=";
  for (auto it = v.begin(); it != v.end(); it++) {
    cerr << *it << " ";
  }
  cerr << endl;
}

template<typename T>
void _dumpv2(const char* s, T&& v)
{
  cerr << *s << "=";
  for (auto it = v.begin(); it != v.end(); it++) {
    cerr << it->first << ":" << it->second << " ";
  }
  cerr << endl;
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__)
#define dumpv(...) _dumpv(#__VA_ARGS__, __VA_ARGS__)
#define dumpv2(...) _dumpv2(#__VA_ARGS__, __VA_ARGS__)

const ll MOD = 1000000007;

ll XOR(ll a)
{
  dump(a);
  if ((a & 1) == 0) {
    return ((a >> 1) & 1) ^ a;
  } else {
    return ((a + 1) >> 1) & 1;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("template.1", "r", stdin);

  ll A, B;
  cin >> A >> B;
  vector<int> Ab(64);
  vector<int> Bb(64);
  vector<int> Db(64);
  for (int i = 0; i < 63; i++) {
    if (A & (1LL << i)) {
      Ab[i] = 1;
    }
    if (B & (1LL << i)) {
      Bb[i] = 1;
    }
  }
  cerr << XOR(A - 1) << endl;
  cerr << XOR(B) << endl;
  ll ans;
  ans = XOR(A - 1) ^ XOR(B);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
    int N(0);
    cin >> N;
    int ac(0), wa(0), tle(0), re(0);
    
    for(int i = 0; i < N; ++i){
        string t;
        cin >> t;
        if(t == "AC")
            ++ac;
        else if(t == "WA")
            ++wa;
        else if(t == "TLE")
            ++tle;
        else if(t == "RE")
            ++re;
    }
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    
    return 0;
}


Measured memory_bytes: 3564
using System;
using System.Text.RegularExpressions;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int len=Convert.ToInt32(Console.ReadLine());
            double[] numlist = new double[len];
            int tmp = 0;
            foreach(string x in Regex.Split(Console.ReadLine(), @"\s+"))
            {
                numlist[tmp] = Convert.ToDouble(x);
                tmp += 1;
            }
            double toplength = 0, tmplength = 0;
            for(int i = len-2; i >=0; --i)
            {
                if (numlist[i+1] <= numlist[i])
                    tmplength += 1;
                else
                {
                    tmplength = 0;
                    if (toplength > i + 1)
                        break;
                }
                if (toplength < tmplength)
                    toplength = tmplength;
            }
            Console.WriteLine(toplength);
        }
    }
}


Measured memory_bytes: 33072
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

int field[5][5];

main(){
	int m;
	cin>>m;
	
	while(m--){
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				cin>>field[i][j];
			}
		}
		int maxsize=0;
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				for(int k=i;k<5;k++){
					for(int l=j;l<5;l++){
						int all1=1;
						for(int s=i;s<=k;s++){
							for(int t=j;t<=l;t++){
								if(field[s][t]==0){
									all1=0;
									break;
								}
							}
							if(all1==0)break;
						}
						if(all1)maxsize=max(maxsize,(k-i+1)*(l-j+1));
					}
				}
			}
		}
		cout<<maxsize<<endl;
	}
}

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

using namespace std;

int main(){

    int a,b,c,x,cont=0;
    int A=500,B=100,C=50;

    cin >> a >> b >> c >> x;

    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if((i*A)+(j*B)+(k*C) == x){
                    cont++;
                }
            }
        }
    }

    cout << cont << endl;

    return 0;
}

Measured memory_bytes: 256