akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using vis=vector<string>;
using vvi=vector<vi>;
//pとqの最大公約数
int gcd(int p,int q){
    if(p%q==0)
    return q;
    return gcd(q,p%q);
}
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<(n/(a+b)*a)+min(a,n%(a+b))<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
const int maxn=100100;
int f1[maxn],f2[maxn];
int cnt1[maxn],cnt2[maxn];
int beg[maxn],nex[maxn<<1],tto[maxn<<1],e;
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
int val[maxn];
struct node{
	int s,t;
}w[maxn<<1];
int num;
void setgraph(){
	memset(beg,0,sizeof(beg));
	e=0;
}
int dfs(int u){
	int v=-1,t;
	if(cnt1[u]&1) v=u;
	for(int i=beg[u];i;i=nex[i]){
		t=dfs(tto[i]);
		if(v==-1) v=t;
		else w[++num]=(node){v,t},v=-1;
	}
	if(v==-1){
		printf("IMPOSSIBLE\n");
		exit(0);
	}
	return v;
}
void color(int u,int v){
	val[u]=v;
	for(int i=beg[u];i;i=nex[i]){
		if(val[tto[i]]){
			if(val[tto[i]]==val[u]){
				printf("IMPOSSIBLE\n");
				exit(0);
			}
		}
		else
			color(tto[i],-v);
	}
}
int main(){
//	freopen("F.in","r",stdin);
//	freopen("F.out","w",stdout);
	int n,rt;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&f1[i]);
		if(f1[i]>0) cnt1[f1[i]]++;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&f2[i]);
		if(f2[i]>0) cnt2[f2[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		cnt1[i]=!(cnt1[i]&1);
		cnt2[i]=!(cnt2[i]&1);
		if(cnt1[i]!=cnt2[i]){
			printf("IMPOSSIBLE\n");
			return 0;
		}
	}

	setgraph();
	for(int i=1;i<=n;i++)
	{
		if(f1[i]>0)
			putin(f1[i],i);
		else
			rt=i;
	}
	dfs(rt);

	setgraph();
	for(int i=1;i<=n;i++)
	{
		if(f2[i]>0)
			putin(f2[i],i);
		else
			rt=i;
	}
	dfs(rt);
	
	setgraph();
	for(int i=1;i<=num;i++)
	{
		putin(w[i].s,w[i].t);
		putin(w[i].t,w[i].s);
	}

	for(int i=1;i<=n;i++)
		if(!val[i]&&(cnt1[i]&1))
			color(i,1);

	printf("POSSIBLE\n");
	for(int i=1;i<=n;i++)
		printf("%d ",val[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 7424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B {
    class questionB {
        static void Main(string[] args) {
            string[] input = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            string A = input[0];
            string B = input[1];
            int N = int.Parse(A + B);
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            if (Math.Sqrt(N) % 1 == 0) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABC = Console.ReadLine().Split(' ');
            Console.WriteLine((ABC[0]== ABC[1] && ABC[1] != ABC[2]) || (ABC[0] == ABC[2] && ABC[1] != ABC[2]) || (ABC[1] == ABC[2] && ABC[0] != ABC[2]) ? "Yes":"No");
        }
    }
}


Measured memory_bytes: 13140
def main():
    S = str(input())
    odd = (len(S) // 2) + (len(S) % 2)
    even = len(S) // 2
    check_odd = 0
    check_even = 0
    c = 0
    for i in range(odd):
        if S[c] == 'R' or S[c] == 'U' or S[c] == 'D':
            check_odd = check_odd + 1
        c = c + 2
    c = 1
    for i in range(even):
        if S[c] == 'L' or S[c] == 'U' or S[c] == 'D':
            check_even = check_even + 1
        c = c + 2
    if check_even == even and check_odd == odd:
        print('Yes')
    else:
        print('No')
main()  

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    char al; cin >> al;
    if('a'<= al && al <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
}

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

int main(){
while(true){
	int h,w;
	cin>>h>>w;

	if(h==0&&w==0)break;

	int d=h*h+w*w;

	int H=150;
	int W=150;
	int D=150*150+150*150;

	for(int y=1;y<=150;y++){
		for(int x=y+1;x<=150;x++){
			int z=y*y+x*x;
			if(z<=d){
				continue;
			}
			else{
 				if(z<D){
					H=y;
					W=x;
					D=z;
				}
				break;
			}
		}
	}
	for (int y=h+1;y<150;y++){
		bool flg=false;
		for(int x=y+1;x<=150;x++){
			int z=y*y+x*x;
			if(z==d){
				H=y;
				W=x;
				D=z;
				flg=true;
			}
			if(z>=d)break;
		}
		if(flg)break;
	}
	cout<<H<<' '<<W<<endl;
}
return 0;

}



Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a<b)cout<<"a < b"<<endl;
    if(a>b)cout<<"a > b"<<endl;
    if(a==b)cout<<"a == b"<<endl;
}



Measured memory_bytes: 3100
#include<iostream>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<string.h>
#include<cmath>
using namespace std;
int main()
{
	long long  a,n,sum=0;
	long long b[100000];
	cin >> a >> n;
	for (long long i = 0; i < n; i++)
	{
		cin >> b[i];
		sum += b[i];
	}
	if (sum >= a) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
    int main(){
        char b;
            cin >> b;
                if(b == 'A'){
                    cout << 'T' << endl;
                }else if(b == 'T'){
                    cout << 'A' << endl;
                }else if(b == 'C'){
                    cout << 'G' << endl;
                }else if(b == 'G'){
                    cout << 'C' << endl;
                }else{}
    return 0;}

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    int ans = 0;
    int x = 0;
    for (int i=0; i<n; i++) {
        if (s[i] == 'I') x++, ans=max(ans,x);
        else x--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
D={}
for y in range(H):
    S=input()
    for s in S:
        if s in D:
            D[s]+=1
        else:
            D[s]=1

if (H%2)+(W%2)==0:
    F=True
    for s in D:
        if D[s]%4:
            F=False
elif (H%2)+(W%2)==1:
    if H%2:
        H,W=W,H

    F=True
    G=0
    for s in D:
        if D[s]%2:
            F=False
        elif D[s]%4==2:
            G+=1
    if G>H//2:
        F=False
else:
    G=0
    I=0
    for s in D:
        if D[s]%2:
            I+=1
        elif D[s]%4==2:
            G+=1
    F=(I==1) and (G<=(H+W-2)//2)

if F:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 65272
#include <bits/stdc++.h>
#define ll long long
#define inf 1e9+10
#define eps 1e-7
using namespace std;
inline ll read(){
	ll x=0;ll f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
ll xx1,xx2,yy1,yy2,xx3,xx4,yy3,yy4;
int main(){
	xx1=read();yy1=read();
	xx2=read();yy2=read();
	if(xx1>=xx2&&yy1>=yy2){
		ll b=xx1-xx2;ll a=yy1-yy2;
		xx3=xx2+a;yy3=yy2-b;
		xx4=xx1+a;yy4=yy1-b;
	}
	else if(xx1<=xx2&&yy1<=yy2){
		ll b=xx2-xx1;ll a=yy2-yy1;
		xx3=xx2-a;yy3=yy2+b;
		xx4=xx1-a;yy4=yy1+b;
	}
	else if(xx1>=xx2&&yy1<=yy2){
		ll a=xx1-xx2;ll b=yy2-yy1;
		xx3=xx2-b;yy3=yy2-a;
		xx4=xx1-b;yy4=yy1-a;
	}
	else if(xx1<=xx2&&yy1>=yy2){
		ll a=xx2-xx1;ll b=yy1-yy2;
		xx3=xx2+b;yy3=yy2+a;
		xx4=xx1+b;yy4=yy1+a;
	}
	printf("%lld %lld %lld %lld\n",xx3,yy3,xx4,yy4);
	return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
x3, y3 = x1 + (x2 - x1 - y2 + y1), y1 + (x2 - x1 + y2 - y1)
x4, y4 = x1 - (y2 - y1), y1 + (x2 - x1)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int a=cin.nextInt(),b=cin.nextInt();
		
		if(a<b)System.out.println("a < b");
		else if(a>b)System.out.println("a > b");
		else System.out.println("a == b");
	}

}



Measured memory_bytes: 26176
#include <limits>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
template<typename Type> class StarrySkyTree {
private:
	unsigned size_; std::vector<Type> dat1, dat2;
	inline void update_(unsigned a, unsigned b, Type x, unsigned k, unsigned l, unsigned r) {
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) {
			dat2[k] += x; return;
		}
		update_(a, b, x, (k << 1), l, (l + r) >> 1);
		update_(a, b, x, (k << 1) + 1, (l + r) >> 1, r);
		dat1[k] = std::min(dat1[k << 1] + dat2[k << 1], dat1[(k << 1) + 1] + dat2[(k << 1) + 1]);
	}
	inline Type query_(unsigned a, unsigned b, unsigned k, unsigned l, unsigned r) {
		if (r <= a || b <= l) return std::numeric_limits<Type>::max();
		if (a <= l && r <= b) return dat1[k] + dat2[k];
		Type lc = query_(a, b, (k << 1), l, (l + r) >> 1);
		Type rc = query_(a, b, (k << 1) + 1, (l + r) >> 1, r);
		return std::min(lc, rc) + dat2[k];
	}
public:
	StarrySkyTree() : size_(0), dat1(std::vector<Type>()), dat2(std::vector<Type>()) {};
	StarrySkyTree(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat1.resize(size_ << 1, 0);
		dat2.resize(size_ << 1, 0);
	}
	inline unsigned size() { return size_; }
	inline void add(unsigned i, Type x) {
		update_(i, i + 1, x, 1, 0, size_);
	}
	inline void add(unsigned l, unsigned r, Type x) {
		update_(l, r, x, 1, 0, size_);
	}
	inline Type query(unsigned l, unsigned r) {
		return query_(l, r, 1, 0, size_);
	}
};
const int inf = 1012345678;
int n, m, dp[500009]; string s, t;
int solve() {
	t += 'X';
	StarrySkyTree<int> v1(n + 1), v2(n + 1);
	for (int i = 0; i < n; i++) {
		if (t[i] == 'B' && (i == 0 || t[i - 1] == 'W')) {
			v1.add(0, i + 1, 1);
		}
		if (t[i] == 'W' && (i == 0 || t[i - 1] == 'B')) {
			v2.add(0, i + 1, 1);
		}
		dp[i + 1] = inf;
		if (s[i] == t[i]) dp[i + 1] = dp[i];
		int res1 = v1.query(max(0, i - m + 1), i + 1) + 1;
		int res2 = v2.query(max(0, i - m + 1), i + 1) + 1;
		dp[i + 1] = min({ dp[i + 1], res1, res2 });
		v1.add(i + 1, (t[i + 1] == 'W' ? dp[i + 1] : inf));
		v2.add(i + 1, (t[i + 1] == 'B' ? dp[i + 1] : inf));
	}
	t.pop_back();
	return dp[n];
}
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m >> s >> t;
	int ret = solve();
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 22896
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#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;
int main()
{
  int n,m;
  cin >> n >> m;
  vector<vector<int>> edge(n);
  rep(i,m){
    int s,t;
    cin >> s >> t;
    s--;
    t--;
    edge[s].push_back(t);
  }

  vector<double> e(n,0);
  for(int v=n-2;v>=0;--v){
    double x = edge[v].size();
    for(auto w:edge[v]){
      e[v] += e[w]/x;
    }
    e[v] += 1.;
  }

  // rep(i,n){
  //   cout << i << ":" << e[i] << "\n";
  // }

  double res = 1e+15;
  rep(v,n){
    if(edge[v].size()<=1){
      res = min(res,e[0]);
      continue;
    }
    double mx=0,sum=0,x=edge[v].size();
    vector<double> ee=e;
    for(auto w:edge[v]){
      sum += e[w];
      mx = max(mx,e[w]);
    }
    sum -= mx;
    ee[v] = sum/(x-1.)+1.;
    if(v!=0){
      for(int vv=v-1;vv>=0;--vv){
	ee[vv] = 0.;
	double xx = edge[vv].size();
	for(auto ww:edge[vv]){
	  ee[vv] += ee[ww]/xx;
	}
	ee[vv] += 1.;
      }
    }
    res = min(res,ee[0]);
  }

  printf("%.7f\n", res);
  return 0;
}


Measured memory_bytes: 1408
/*
      author  : nishi5451
      created : 14.08.2020 16:02:32
*/

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


int main(){
    int n;
    cin >> n;
    int N = n;
    int sum = 0;
    while(n){
        sum += n%10;
        n/=10;
    }
    if(N%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

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

using namespace std;

int main(){
    ll N,tmp;
    cin >> N;
    string res = "YES";
    ll wa = 0;
    REP(i,N)
    {
        cin >> tmp;
        wa += tmp;
    }
    //総和が奇数か
    if(wa % 2 != 0)res = "NO";
    cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, n;
    cin >> h >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum += a[i];
    }
    if (sum >= h)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string s, t; cin >> s >> t;
    Out(t + s);

    return 0;
}


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

int main(){
  int a,b,x,y;
  cin>>a>>b;
  if(a>b){
    x=a;
    if(a-1>b) y=a+a-1;
    else y=a+b;
  }
  else{
    x=b;
    if(b-1>a) y=b+b-1;
    else y=b+a;
  }
  cout<<y;
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define MOD 1000000007
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

ll dp[1001][1001];

int main(){
    std::ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    string board[h] = {};
    for(int i=0;i<h;++i)
    {
      cin >> board[i];
    }
    dp[0][0] = 1;
    for(int i=0;i<h;++i)
    {
      for(int j=0;j<w;++j)
      {
        if(board[i][j] != '.') continue;
        if(i > 0 && j > 0)
        {
          dp[i][j] = dp[i-1][j] + dp[i][j-1];
          dp[i][j] %= MOD;
        }else if(i > 0)
        {
          dp[i][j] = dp[i-1][j];
        }else if(j > 0){
          dp[i][j] = dp[i][j-1];
        }
      }
    }

    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll x){ cout << x << " "; }
void od(ld x){ cout << fixed << setprecision(10) << x << " "; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

int main(){
    ll i;
    ii(i);
    ll a=i/500;
    ll b=(i-a*500)/5;
    oie(a*1000+b*5);

    return 0;
}


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

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s;
	cin >> s;
	int q;
	cin >> q;
	int reverses = 0;
	for (int i = 0; i < q; i++) {
		int op;
		cin >> op;
		reverses += op == 1;
		if (op == 2) {
			int f;
			char c;
			cin >> f >> c;
			if ((f == 1 && reverses % 2 == 0) || (f == 2 && reverses % 2)) {
				s.insert(s.begin(), c);
			} else {
				s += c;
			}
		}
	}
	if (reverses % 2) {
		reverse(s.begin(), s.end());
	}
	cout << s << "\n";
}



Measured memory_bytes: 912
#include <iostream>

using namespace std;

int main(){
  string a, b;
  cin >> a >> b;
  int ans=1;
  if(a=="D"){ans*=-1;}
  if(b=="D"){ans*=-1;}
  if(ans<0){
    cout << "D" << endl;
  }else{
    cout << "H" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9;
const long long LLINF = 1e18;

ll n, a, b, sum;
int main() {
    cin>>n>>a>>b;

    REP(i, 1, n+1){
        ll val=i;
        ll tmp=0;
        while(val>0){
            tmp+=(val%10);
            val/=10;
        }
        if(tmp>=a && tmp<=b) sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int A, B;
int ans;

int main(){
	cin >> A >> B;
	if (A < 10 && A > 0){
		if (B < 10 && B > 0){
			ans = A*B;
			cout << ans << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times {|i|yield(i)}                    end
def repl(st,en,n=1);       n*= -1 if st>en;st.step(en,n){|i|yield(i)} end


a,b,c = gi

puts (a+b-c == 0 ) || (a+c-b == 0 ) || (b+c-a == 0) ? 'Yes' : 'No'


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int main() {
    int a,b; cin >> a >> b;
    int ans = 0;
    if(b!=1) {
        ans++;
        b-=a;
        while(b > 0) {
            b = b+1-a;
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    int m = in.readInt(); 
	    int arr[] = new int[m]; 
	    for(int i = 0; i<n; i++) {
	    	int k = in.readInt(); 
	    	for(int j = 0; j<k; j++) {
	    		int a = in.readInt(); 
	    		arr[a-1]++;
	    	}
	    }
	    int ans = 0; 
	    for(int i = 0; i<m; i++) {
	    	if(arr[i] == n) ans++;
	    }
	    System.out.println(ans);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353ll
int d[100010];
int n;
#define ll long long
ll pow(int a,int b){
    if(b==1)return a;
    else if(b==0)return 1;
    ll ans=pow(a,b/2);
    ans*=ans;
    ans%=mod;
    if(b%2)ans*=a,ans%=mod;
    return ans;
}
int main(){
    cin>>n;
    int mx=0;
    bool ok=1;
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        if(i!=0&&x==0)ok=0;
        mx=max(mx,x);
        d[x]++;
    }
    for(int i=0;i<=mx;i++){
        if(!d[i])ok=0;
    }
    if(!ok){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    for(int i=1;i<=mx;i++){
        ans*=pow(d[i-1],d[i]);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
public class c
{
  public static void Main()
  {
    int n=int.Parse(Console.ReadLine());
    long m=0;
    long a=0;
    long r=0;
    long c=0;
    long h=0;
    for(int i=0;i<n;i++)
    {
      string s=Console.ReadLine();
      if(s[0]=='M')m++;
      else if(s[0]=='A')a++;
      else if(s[0]=='R')r++;
      else if(s[0]=='C')c++;
      else if(s[0]=='H')h++;
    }
    long ans=m*a*r;
    ans+=m*a*c;
    ans+=m*a*h;
    ans+=m*r*c;
    ans+=m*r*h;
    ans+=m*c*h;
    ans+=a*r*c;
    ans+=a*r*h;
    ans+=a*c*h;
    ans+=r*c*h;
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13140
import math
a, b, x = map(int, input().split())
cap = a*a*b
c = 0
if x > cap/2:
    c = ((cap-x) * 2 / (a**2)) / a
else: c = b / (x * 2 / (a * b))
print(math.degrees(math.atan(c)))


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

# define ll long long
# define line cout << "\n" ;

# define fast ios_base :: sync_with_stdio ( false ) ; cin.tie ( 0 ) ; cout.tie ( 0 ) ;

const int N = 1e6 + 3 , mod = 1e9 + 7 ;
ll fact[N] ;

void pre_compute ()
{
    fact[0] = 1 ;
    for ( int i = 1 ; i < N ; i ++ )
    {
        fact[i] = fact[i - 1] * i ;
        fact[i] %= mod ;
    }
}

void solve ()
{
    ll a , b ;
    cin >> a >> b ;

    ll diff = abs ( a - b ) ;
    if ( diff > 1 ) { cout << 0 ; line ; return ; }

    ll ans = fact[a] * fact[b] ;
    ans %= mod ;

    ll x = 1 ;
    if ( a == b ) x = 2 ;

    ans *= x ;
    ans %= mod ;

    cout << ans ; line ;
}

int main()
{fast
//    freopen ( "input.txt" , "r" , stdin ) ;
//    freopen ( "output.txt" , "w" , stdout ) ;

    pre_compute () ;

    int t = 1 ;
    // cin >> t ;

    while ( t -- )
        solve ( ) ;

    return 0 ;
}


Measured memory_bytes: 8064
import java.util.*;
class Main{

    public static void main(String args[]){
	int w,n;
	int[][] Edge;
	int[] Ans;
	Scanner in = new Scanner(System.in);
	String[] s;

     
	w = in.nextInt();
	n = in.nextInt();
	Edge = new int[w+1][2];
	Ans = new int[w+1];
	for(int i=1;i<=w;i++)Ans[i] = i;
	for(int i=0;i<n;i++){
	    s = in.next().split(",");
	    Edge[i][0] = Integer.valueOf(s[0]).intValue();
	    Edge[i][1] = Integer.valueOf(s[1]).intValue();
	    int h = Ans[Edge[i][0]];
	    Ans[Edge[i][0]] = Ans[Edge[i][1]];
	    Ans[Edge[i][1]] = h;
	}
    
	for(int i=1;i<=w;i++)System.out.println(Ans[i]);

    }



}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
int main()
{
	IOS
	ll n;
	cin>>n;
	ll a[n];
	rep(i,0,n)
	{
		cin>>a[i];
	}
	ll ans,cnt=0;
	ans=0;
	rep(i,1,n)
	{
		if(a[i]<=a[i-1])
		{
			cnt++;
			ans=max(ans,cnt);
		}
		else
		{
			cnt=0;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <string>

using namespace std;

int main(void){
	int n, m, i, j;
	char org[257], x, y;
//	FILE* f;
//	f = fopen("test.txt","w");
	while(1){
		scanf("%d%*c",&n);
		if(!n){
			break;
		}
		for(i = 0;i < 256;i++){
			org[i] = (char)i;
		}
		for(i = 0;i < n;i++){
			scanf("%c%*c%c%*c",&x,&y);
			org[x] = y;
		}
		scanf("%d%*c",&m);
		for(i = 0;i < m;i++){
			x = getchar();
			getchar();
			printf("%c",org[x]);
		}
		printf("\n");
	}
//	fclose(f);
	return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;

  int dis = 0;
  int ans = 1;

  for (int i = 0; i < N; i++) {
    int L;
    cin >> L;
    dis += L;
    if (dis <= X) ans++;
    else break;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const ll inf=1e15;
const int MAXN=2e5+5;
const int MAXT=MAXN*4;
const int MAXM=MAXN*20*20;
struct tnode{
	int l,r,cl,cr;
} t[MAXN];
int n,m,M,rt;
int edge,head[MAXT*2],nex[MAXM],tail[MAXM];
ll w[MAXM],dist[MAXT*2];
bool use[MAXT*2];
struct rec{
	int u;
	ll dist;
	bool operator < (const rec& b) const{
		return dist>b.dist;
	}
};
priority_queue<rec> q;
vector<int> lis;
void add(int u,int v,ll W){
//	cout<<"id:"<<u<<" l:"<<t[u/2].l<<" r:"<<t[u/2].r<<endl;
//	cout<<"id:"<<v<<" l:"<<t[v/2].l<<" r:"<<t[v/2].r<<endl;
//	cout<<W<<endl;
	edge++,nex[edge]=head[u],head[u]=edge,tail[edge]=v,w[edge]=W;
}
int newnode(int l,int r,int cl,int cr){
	t[++M]=(tnode){l,r,cl,cr};
	return M;
}
int build(int l,int r){
	if (l==r) return newnode(l,r,0,0);
	int mid=(l+r)>>1;
	int id=newnode(l,r,0,0);
	int cl=build(l,mid),cr=build(mid+1,r);
	t[id].cl=cl; if (cl) add(2*cl,2*id,0),add(2*id+1,2*cl+1,0);
	t[id].cr=cr; if (cr) add(2*cr,2*id,0),add(2*id+1,2*cr+1,0);
	return id;
}
void qry(int a,int b,int id){
	int l=t[id].l,r=t[id].r;
	int cl=t[id].cl,cr=t[id].cr;
	if (l>b||r<a) return;
	if (a<=l&&r<=b){
		lis.push_back(id);
		return;
	}
	qry(a,b,cl); qry(a,b,cr);
}
int main(){
	scanf("%d%d",&n,&m);
	rt=build(1,n);
	for (int i=1;i<=m;i++){
		int l,r; ll x; scanf("%d%d%lld",&l,&r,&x);
		lis.clear();
		qry(l,r,rt);
		for (int i=0;i<lis.size();i++){
			int u=lis[i];
			for (int j=0;j<lis.size();j++){
				int v=lis[j];
				add(2*u,2*v+1,x);
				if (u!=v) add(2*v+1,2*u,x);
				else add(2*v+1,2*u,0);
			}
		}
	}
	for (int i=1;i<=2*M+3;i++) dist[i]=inf;
	lis.clear(); qry(1,1,rt);
	q.push((rec){2*lis[0],0}); dist[2*lis[0]]=0;
	while (!q.empty()){
		rec u=q.top(); q.pop();
		if (use[u.u]) continue;
		use[u.u]=1;
		for (int e=head[u.u];e;e=nex[e]){
			int v=tail[e];
			if (dist[v]>dist[u.u]+w[e]){
				dist[v]=dist[u.u]+w[e];
				q.push((rec){v,dist[v]});
			}
		}
	}
	lis.clear(); qry(n,n,rt);
	ll ans=dist[2*lis[0]+1];
	printf("%lld\n",ans==inf?-1ll:ans);
	return 0;
}


Measured memory_bytes: 710248
n = int(input())
S = []
al = [chr(ord('a') + i) for i in range(26)] 
for i in range(n):
    s = input()
    S.append(s)
ans = ''
for a in al:
    m = 50
    for i in range(n):
        if S[i].count(a) < m:
            m = S[i].count(a) 
    ans += a*m
print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<pair<string,int>> ans(n);
    map<pair<string,int>,int> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int p;
        cin >> p;
        ans[i] = {s,-p};
        mp[ans[i]] = i+1;
    }     
    sort(ans.begin(),ans.end());
    for(int i = 0; i < n; i++){
        cout << mp[ans[i]] << endl;
    }
}

Measured memory_bytes: 256
use std::io;

fn get_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .unwrap();
  line
}

fn line_to_vec_usize(line: &str) -> Vec<usize> {
  line
    .trim()
    .split_whitespace()
    .map(|val| { val.parse::<usize>().unwrap() })
    .collect()
}

fn include_3(mut n: i64) -> bool {
  let ans: bool;
  loop {
    if n % 10 == 3 {
      ans = true;
      break;
    }
    else if n == 0 {
      ans = false;
      break;
    }
    n /= 10;
  }
  ans
}

fn main() {
  let n = line_to_vec_usize(&get_line())[0];
  let mut vec: Vec<i64> = Vec::with_capacity(n);
  for i in 1..(n + 1) {
    if i % 3 == 0 || include_3(i as i64) {
      vec.push(i as i64);
    }
  }
  let ans = vec.iter()
    .map(|val| val.to_string())
    .collect::<Vec<String>>();
  println!(" {}", ans.join(" "));
}



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

int main() {

 string S,T;
  cin >> S >> T;
  int a;
  a= T.size();
  char ss;
  ss= T.at(a-1);
  S.append(1, ss);  
  if(S==T){
    
    cout <<"Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;

}


Measured memory_bytes: 3632
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#import fractions
#S=input()
#import math
#n=int(input())

ans=0
lis=list(map(int,input().split()))
k=[]
for i in range(lis[1]):
    a=list(map(int,input().split()))
    k.append(a)
p=list(map(int,input().split()))
for i in range(2**lis[0]):
    a=str(bin(2**(lis[0]+1)-i-1))[3:]
    #print(a)
    for j in range(lis[1]):
        flag=0
        s=0
        for l in range(k[j][0]):
            s+=int(a[k[j][l+1]-1])
        if s%2!=p[j]:
            flag=1
            break
    if flag==0:
        ans+=1


print(ans)


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

long long modpow(long long base, long long power, long long modvalue) {
    base%= modvalue;
    long long res = 1;
    while (power > 0) {
        if (power & 1)
            res = res * base % modvalue;
        base = base * base % modvalue;
        power >>= 1;
    }
    return res;
}


long long get_modpow_value(string &s, long long ones){
    long long n = s.size();
    long long modpow_value = 0;
    for(long long i = 0; i < n; i++){
        if(s[i] == '1'){
            modpow_value += modpow(2, n - i - 1, ones);
            modpow_value %= ones;
        }
    }
    
    return modpow_value%ones;
}

int main(){
    long long n;
    string s;
    cin >> n >> s;
    
    long long ones = 0;
    for(long long i = 0; i < n; i++){
        if(s[i] == '1'){
            ones += 1;
        }
    }
    long long possible_rem1 = 0, possible_rem2 = 0;
    if(ones > 1)possible_rem1 = get_modpow_value(s, ones - 1);
    if(ones >= 0)possible_rem2 = get_modpow_value(s, ones + 1);
     
    for(long long i = 0; i < n; i++){
        long long current_ones = ones;
        long long rem;
        if(s[i] == '0'){
            current_ones += 1;
            rem = possible_rem2 + modpow(2, n - 1 - i, current_ones);
            rem %= current_ones; 
        }else{
            current_ones -= 1;
            if(current_ones == 0){
                cout << 0 << endl;
                continue;
            }   
            rem = possible_rem1 - modpow(2, n - 1 - i, current_ones);
            rem = (current_ones + (rem % current_ones)) % current_ones;
        }
        
        long long res = 1;
        while(rem != 0){
            res += 1;
            rem = rem%__builtin_popcount(rem);
        }
        cout << res << endl;
    }
    
    return 0;
    
    
}


Measured memory_bytes: 3736
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e5+5;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
 if(a+b >= mod)
        return a+b-mod;
    return a+b;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
vi v;
string r;
ll d;
ll dp[10005][102][2];
void fil(string x){
    fr1(i,sz(x))v.pb(x[i]-'0');
    //fr1(i,sz(v))cout<<v[i]<<" ";
}
ll solve(ll pos,ll sum,ll f){
    if(pos==sz(v)){
        if(sum==0)return 1;
        return 0;
    }
    if(dp[pos][sum][f]!=-1)return dp[pos][sum][f];
    ll lmt=9;
    if(f==0)lmt=v[pos];
    ll ans=0;
    for(int dgt=0;dgt<=lmt;dgt++){
        ll nf=f;
        if(dgt<lmt)nf=1;
        ans=add(ans,solve(pos+1,(sum+dgt)%d,nf));
    }
    return dp[pos][sum][f]=ans;
}
ll give(string x){
    v.clear();
    memset(dp,-1,sizeof(dp));
    fil(x);
    return solve(0,0,0);
}
int main(){
    fio;
    cin>>r>>d;
    ll x=give(r);
    x-=1;
    if(x<0)x+=mod;
    cout<<x;
    return 0;
}

Measured memory_bytes: 17176
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll fac[maxn],inv[maxn],n,k;
char s[maxn];
const ll mod=1000000007;

inline ll pw(ll a,ll b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=(ans*base)%mod;
		base=(base*base)%mod; b>>=1;
	}
	return ans;
}

inline ll C(int N,int M){return (fac[N]*inv[M]%mod)*inv[N-M]%mod;}

int main()
{
	fac[0]=1; inv[0]=1; ll n=read(),ans=0; scanf("%s",s+1); k=strlen(s+1);
	rep(i,1,(maxn-5)) fac[i]=(fac[i-1]*i)%mod;
	rep(i,1,(maxn-5)) inv[i]=pw(fac[i],mod-2);
	rep(i,0,n)
	{
		ll p=(pw(26,n-i)%mod*pw(25,i)%mod)%mod; p=(p*C(k+i-1,i))%mod;
		ans=(ans+p)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35988
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	vector<int> c(N, -1);
	c[0] = 0;
	deque<int> que;
	que.emplace_back(0);
	while (!que.empty()) {
		int u = que.front(); que.pop_front();
		for (auto v : g[u]) {
			if (c[v] >= 0) { continue; }
			c[v] = 1 - c[u];
			que.emplace_back(v);
		}
	}

	vector<int> Vo, Ve;
	for (int i = 0; i < N; ++i) {
		if (c[i]) { Vo.emplace_back(i); }
		else { Ve.emplace_back(i); }
	}

	deque<int> p0, p1, p2;
	for (int i = 1; i <= N; ++i) {
		if (i % 3 == 0) { p0.emplace_back(i); }
		else if (i % 3 == 1) { p1.emplace_back(i); }
		else { p2.emplace_back(i); }
	}
	
	vector<int> ans(N, -1);
	if (Vo.size() > N / 3 && Ve.size() > N / 3) {
		for (int v : Ve) {
			if (!p1.empty()) {
				ans[v] = p1.front(); p1.pop_front();
			} else if (!p0.empty()) {
				ans[v] = p0.front(); p0.pop_front();
			}
		}
		for (int v : Vo) {
			if (!p2.empty()) {
				ans[v] = p2.front(); p2.pop_front();
			} else if (!p0.empty()) {
				ans[v] = p0.front(); p0.pop_front();
			}
		}
	} else {
		vector<int> V1 = (Vo.size() < Ve.size() ? Vo : Ve);
		vector<int> V2 = (Vo.size() < Ve.size() ? Ve : Vo);
		for (int v : V1) {
			ans[v] = p0.front(); p0.pop_front();
		}
		for (int v : V2) {
			if (!p0.empty()) {
				ans[v] = p0.front(); p0.pop_front();
			} else if (!p1.empty()) {
				ans[v] = p1.front(); p1.pop_front();
			} else if (!p2.empty()) {
				ans[v] = p2.front(); p2.pop_front();
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		cout << ans[i] << (i < N - 1 ? " " : "\n");
	}

	return 0;
}


Measured memory_bytes: 16884
let n, t = Scanf.scanf " %d %d" @@ fun a b -> a, b
let cts = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let cts = List.filter (fun (_, t0) -> t0 <= t) cts |> List.sort compare
let _ = if cts = [] then print_endline "TLE" else List.hd cts |> fst |> Printf.printf "%d\n"

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(10);
  ll n;
  cin >> n;
  double d;
  multiset<double> v;
  for(ll i = 0; i < n; ++i){
    cin >> d;
    v.insert(d);
  }
  double a,b;
  while(v.size() > 1){
    a = *begin(v);
    v.erase(begin(v));
    b = *begin(v);
    v.erase(begin(v));
    v.insert((a+b)/2);
  }
  cout << *begin(v);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b;
  cin>>a>>b;
  if(a>12)cout<<b;
  else if(a>5)cout<<b/2;
  else cout<<0;
}


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

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}

int main(void){
	int h=in(),w=in(),i,j,k,f[100][100];
	char s[100][101];
	memset(f,-1,sizeof(f));
	for(i=0;i<h;i++){
		chin(s[i]);
	}
	for(i=0;i<h;i++){
		for(j=w-1;j>=0;j--){
			if(s[i][j]=='c'){
				for(k=0;j+k<w&&f[i][j+k]==-1;k++){
					f[i][j+k]=k;
				}
			}
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			printf("%d%c",f[i][j],j==w-1?'\n':' ');
		}
	}
	return 0;
}

Measured memory_bytes: 656
#include "bits/stdc++.h"

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 5;
const int INF = 2e9;

char grid[21][21];
int n, m;

int dp[21][21];
int cc[21][21];

bool v[21][21];

vector<pair<int, int>> cells[402];

int cur = 1;
void dfs(int x, int y){
	if(x == -1 || y == -1 || x == n || y == m || grid[x][y] == '#') return;

	if(v[x][y]) return;
	v[x][y] = 1;

	cc[x][y] = cur;

	dfs(x + 1, y);
	dfs(x - 1, y);
	dfs(x, y + 1);
	dfs(x, y - 1);

}
int mx = 0;

void solve(int x, int y, int cnt){

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			v[i][j] = (grid[i][j] == '#');
		}
	}
	queue<pair<int, int>> q;

	q.push({x, y});

	v[x][y] = 1;

	while(!q.empty()){
		auto p = q.front();
		q.pop();

		if (p.first - 1 >= 0 &&
			!v[p.first - 1][p.second]) {
			q.push({p.first - 1, p.second});
			mx = max(mx , dp[p.first - 1][p.second] = dp[p.first][p.second] + 1);
			v[p.first - 1][p.second] = true;
		}

		if (p.first + 1 < n &&
			!v[p.first + 1][p.second]) {
			q.push({p.first + 1, p.second});
			mx = max(mx ,dp[p.first + 1][p.second] = dp[p.first][p.second] + 1);

			v[p.first + 1][p.second] = true;
		}

		if (p.second - 1 >= 0 &&
			!v[p.first][p.second - 1]) {
			q.push({p.first, p.second - 1});
			mx = max(mx, dp[p.first][p.second - 1] = dp[p.first][p.second] + 1);

			v[p.first][p.second - 1] = true;
		}

		if (p.second + 1 < m &&
			!v[p.first][p.second + 1]) {
			q.push({p.first, p.second + 1});
			mx = max(mx ,dp[p.first][p.second + 1] = dp[p.first][p.second] + 1);

			v[p.first][p.second + 1] = true;
		}
	}
}

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> grid[i][j];
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(grid[i][j] != '#' && cc[i][j] == 0){
				dfs(i, j);
				cur++;
			}
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(cc[i][j] != 0)
				cells[cc[i][j]].emplace_back(i, j);
		}
	}

	for(auto x : cells){
		for(auto y : x){
			memset(dp, 0, sizeof dp);
			memset(v, 0, sizeof v);
			solve(y.first, y.second, 0);
		}
	}
	
	cout << mx;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define xy fabs(x[j]-y[j])

int main(void)
{
    int j,n;
    double x[1010]={0},y[1010]={0},max=0,p1,p2,p3;
    
    scanf("%d",&n);
    for(j=0;j<n*2;j++){
        if(j<n) scanf("%lf",&x[j]);
        else scanf("%lf",&y[j-n]);
    }
    
    for(j=0;j<n;j++){
        p1+=xy;
        p2+=pow(xy,2);
        p3+=pow(xy,3);
        if(xy>max)max=xy;
    }
    p2=sqrt(p2);
    p3=cbrt(p3);
    printf("%f\n%f\n%f\n%f\n",p1,p2,p3,max);
    
    return 0;
}


Measured memory_bytes: 2020