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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	map<int, int> subs;
	int N; cin >> N;
	F0R(i, N-1) {
		int boss; cin >> boss; --boss;
		subs[boss]++;
	}
	F0R(i, N) {
		print(subs[i]);
	}
}

Measured memory_bytes: 13044
import math

n = int(input())

keta = int(math.log10(n)) + 1

memo = [ [None] * 10 for _ in range(10)]

ans = 0
for a in range(1, n+1):
    x = int(str(a)[0])
    y = a % 10

    if x == 0 or y == 0:
        continue

    if memo[x][y] is not None:
        ans += memo[x][y]
        # print(a, ans)
        continue
    
    patterns = 0
    for b in range(x, n+1, 10):
        x2 = int(str(b)[0])
        y2 = b % 10
        if x == y2 and y == x2:
            patterns += 1
    memo[x][y] = patterns
    ans += patterns

print(ans)

Measured memory_bytes: 41436
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	int a,b,n;
	cin>>a>>b>>n;
	int mi=min(b-1,n);
	if(mi==0)
	{
		
		cout<<0;
		return;
	}
	int ans=(a*mi)/b;
	ans+=(a*(mi/b));
	cout<<ans;
	
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}



Measured memory_bytes: 3640
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]


W, a, b = list(map(int, input().split()))
if b <= a <= b+W or b <= a+W <= b+W:
    print(0)
else:
    ans = min(abs(b+W-a), abs(a+W-b))
    print(ans)


Measured memory_bytes: 3060
n = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = []

while True:
    if n == 0:
        break
    ans.append(alp[n%26-1])
    n = (n - 1) // 26
ans.reverse()
print("".join(list(map(str, ans))))

Measured memory_bytes: 9176
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,A,B;
    cin >> N >> A >> B;
    ll out = 0;
    if(N==1){
        if(A==B) out = 1;
    }
    else if(B<A);
    else out = (N-2)*(B-A)+1;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(k>=s.size()){
        cout<<s<<endl;
    }else{
        string s1 = s.substr(0,k);
        cout<<s1<<"..."<<endl;
    }
    
return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  if(a=="SAT")cout << 1 << endl;
  else if(a=="FRI")cout << 2 << endl;
  else if(a=="THU")cout << 3 << endl;
  else if(a=="WED")cout << 4 << endl;
  else if(a=="TUE")cout << 5 << endl;
  else if(a=="MON")cout << 6 << endl;
  else if(a=="SUN")cout << 7 << endl;
}

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



int fac[310000];

int inv(int x){
  if(x==1) return 1;
  return (M-M/x)*inv(M%x)%M;
}


int comb(int n,int k){
  int x=(fac[k]*fac[n-k])%M;
  return (fac[n]*inv(x))%M;
}

int fac_init(int n){
  fac[0]=1;
  FOR(i,1,n+1){
    fac[i]=fac[i-1]*i;
    fac[i]%=M;
  }
}


main(){
  int n;
  cin>>n;
  int c[110000]={};
  int r,s;
  fac_init(n+2);
  rep(i,n+1){
    int a;
    cin>>a;
    if(c[a]){
      r=c[a];
      s=i;
    }else{
      c[a]=i+1;
    }
  }
  r--;
  //cout<<r<<' '<<s<<endl;
  s=n-s;

  FOR(k,1,n+2){
    int res=comb(n+1,k);

    if(r+s>=k-1)
      res-=comb(r+s,k-1);


    cout<<(res+M)%M<<endl;
   
  }

}


Measured memory_bytes: 2816
#include <stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  int i;
  i = 0;
  int a[n];
  int sum;
  sum = 0;
  int max;
  max = 0;
  while (i < n)
  {
    scanf("%d",&a[i]);
    sum += a[i];
    if (a[i] > max)
      max = a[i];
    i++;
  }
  //printf("sum:%d max:%d",sum,max);
  sum -= max;
  if (sum > max)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N, H, W;
    cin >> N >> H >> W;
    cout << (N - W + 1) * (N - H + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int m,k;
    cin>>m>>k;
    if(k>=(1<<m)){
        cout<<-1<<endl;
        return;
    }
    if(m==0){
        cout<<0<<" "<<0<<endl;
        return;
    }
    if(m==1){
        if(k==0){
            cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
        }
        else{
            cout<<-1<<endl;
        }
        return;
    }
    cout<<k<<" ";
    rep(i,1<<m){
        if(i==k)continue;
        cout<<i<<" ";
    }
    cout<<k<<" ";
    rev(i,1<<m){
        if(i==k)continue;
        cout<<i<<" ";
    }
    cout<<endl;
}

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

int main(void) {
    int N;
    cin >> N;
    ll A[N],B[N];
    ll P,Q,R,S;
    // 累積和
    for(int i=0; i<N; i++) cin >> A[i];
    B[0] = A[0];
    for(int i=1; i<N; i++) B[i] = B[i-1] + A[i];
    ll absL, absR, memoL, memoR;
    ll res = LLONG_MAX;
    int left=0,right=2;
    // 分割の位置
    for(int center=1; center<N-2; center++) {
        if(right == center) right++;
        if(left == center) left--;

        while(left < center) {
            P = B[left];
            Q = B[center] - B[left];
            memoL = absL;
            absL = Q - P;
            if(absL < 0 && left > 0) {
                left--;
                if(abs(memoL) < abs(absL)) {
                    P = B[left];
                    Q = B[center] - B[left];
                }
                break;
            }
            if(left < center-1) left++;
            else break;
        }
        while(right < N) {
            R = B[right] - B[center];
            S = B[N-1] - B[right];
            memoR = absR;
            absR = S - R;
            if(absR < 0 && right > center + 1) {
                right--;
                if(abs(memoR) < abs(absR)) {
                    R = B[right] - B[center];
                    S = B[N-1] - B[right];
                }
                break;
            }
            if(right < N-2) right++;
            else break;
        }

        ll ax = max(P,Q);
        ax = max(ax, R);
        ax = max(ax, S);
        ll ix = min(P,Q);
        ix = min(ix, R);
        ix = min(ix, S);
        res = min(res, ax - ix);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int n,x; cin>>n>>x;
    vector <int> a(n); 
    rep(i,n) cin>>a[i];
    int ans = 0;
    rep(i,n-1){
        if(a[i]+a[i+1] > x){
            
            int sa = + a[i] + a[i+1] - x;
            //cout<<sa<<endl;
            if(sa <= a[i+1]){
                a[i+1]-=sa;
                ans += sa;
            }else{
                ans += a[i+1];
                sa -= a[i+1];
                ans += sa;
                a[i+1] = 0;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
#define ull unsigned long long
const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;
using namespace std;

int main()
{


int n;
cin >> n;

int d1 = n % 10;
n/=10;
int d2 = n % 10;
n/=10;
int d3 = n % 10;
n/=10;
int d4 = n  % 10;
n/=10;

int k = d4 * 10 + d3;
int x = d2 * 10 + d1;

if(k >= 1 and k <= 12)
 {
    if(x >= 1 and x <= 12)
    	 {
    	 	cout << "AMBIGUOUS";
    	 }
    else cout << "MMYY";
 }
 else if(x >= 1 and x <= 12)
 	 {
 	 	cout << "YYMM";
 	 }
 
 else cout << "NA";



} 

Measured memory_bytes: 768
#include <iostream>

using namespace std;

const int MAX = 100007;
int64_t A[MAX], B[MAX], tmp;
int n;

int32_t main()
{
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> A[i] >> B[i];
    for (int i = n-1; i >= 0; --i) tmp += ((A[i] + tmp) % B[i]) ? B[i] - ((A[i] + tmp) % B[i]) : 0;
    cout << tmp;
}


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

int main(void){

    int N,M;
    cin >>N>>M;

    vector<vector<int>> S(M);
    for (int i = 0; i < M; ++i) {
        int k; cin>>k;
        S[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin>>S[i][j];
            S[i][j]--;
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; ++i) {
        cin>>p[i];
    }

    //ここから回答
    int ans = 0;
    for (int i = 0; i < (1<<N); ++i) {//スイッチの組み合わせを全通り
        bool ok = true;
        for (int j = 0; j < M; ++j) {//それぞれの電球で繰り返し
            int kosuu=0;
            for (int k : S[j]) {//電球一つのなかで確かめる
                if((i>>k) & 1){
                    kosuu++;
                }
            }
            kosuu %= 2;
            if(kosuu != p[j]){ok = false; break;}
        }
        if(ok == true) ans++;
    }

    cout<<ans<<endl;

    return 0;
}

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

int main(){

  string str; cin >> str;
  int sum = 0;

  for(int i=0; i<str.size(); i++){
    // convert to integer by diff based on ascii value
    sum += str[i] - '0' ;
  }

  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

//  cout << sum%9 << endl;

  return 0;
}


Measured memory_bytes: 3724
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
#define rep(i,f_start,f_end) for (int i=f_start;i<=f_end;++i)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define MT(x,i) memset(x,i,sizeof(x) )
#define rev(i,start,end) for (int i=start;i<end;i++)
#define inf 0x3f3f3f3f
#define mp(x,y) make_pair(x,y)
#define lowbit(x) (x&-x)
#define MOD 1000000007
#define exp 1e-8
#define N 1000005 
#define fi first 
#define se second
#define pb push_back
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
typedef vector <int> VI;
typedef pair<int ,int> PII;
typedef pair<int ,PII> PIII;
ll gcd (ll a,ll b) {return b?gcd (b,a%b):a; }
inline int read() {
    char ch=getchar(); int x=0, f=1;
    while(ch<'0'||ch>'9') {
        if(ch=='-') f=-1;
        ch=getchar();
    } while('0'<=ch&&ch<='9') {
        x=x*10+ch-'0';
        ch=getchar();
    } return x*f;
}

const int maxn=2e4+10;


int main () {
    string a,b;
    cin>>a>>b;
    int ans=0;
    rev (i,0,a.size ()-b.size ()+1)  {
      int temp=0;
      rev (j,0,b.size ()) {
        //   printf ("%c %c ",a[i+j],b[j]);
          if (a[i+j]==b[j]) temp++;
        //   printf ("%d\n",temp);
          ans=max (temp,ans);
      }
    }
      printf ("%d\n",b.size ()-ans);
    return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  ll n,x;cin>>n>>x;
  vector<ll>num(n);
  for(ll i=0;i<n;i++){
    cin>>num[i];
  }
  sort(ALL(num));
  ll ans=0;
  for(ll i=0;i<n;i++){
    if(num[i]<=x){
      x-=num[i];
      ans++;
    }else{
      x=0;
      break;
    }
  }
  if(x>0)ans--;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9+1;
int main(){
	int a,b;cin>>a>>b;
	if(a>b) swap(a,b);
	rep(i,0,b){
		cout<<a;
	}cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a[100000],b[100000];
int k[100002];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		k[a[i]]++;k[b[i]+1]--;
	}
	for(int i=1;i<=100001;i++)k[i]+=k[i-1];
	int maxn=0;
	for(int i=1;i<=100001;i++){
		if(i-1<=k[i]){
			maxn=i-1;
		}
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 2332
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 51


int main(){
  int n,m;
  char A[SIZE][SIZE], B[SIZE][SIZE];
  
  scanf("%d%d",&n,&m);

  for(int i=0;i<n;i++){
    scanf("%s",A[i]);
  }
  for(int j=0;j<m;j++){
    scanf("%s",B[j]);
  }

  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      bool flag = true;
      
      for(int x=0;x<m;x++){
        for(int y=0;y<m;y++){
          flag &= A[i+y][j+x] == B[y][x];
        }
      }

      if(flag){
        puts("Yes");
        return 0;
      }
    }
  }

  puts("No");
  
  return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n1 = 0, n2 = 0;
    for (int i = 0, l = s.length(); i < l; ++i) {
        if (i % 2 == 0) {
            if (s[i] == '0') ++n1;
            if (s[i] == '1') ++n2;
        } else {
            if (s[i] == '1') ++n1;
            if (s[i] == '0') ++n2;
        }
    }
    cout << min(n1, n2) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int N;
double sum;
int a[51];

int main()
{
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> a[i];
    sort(a + 1, a + N + 1);
    sum = a[1];
    for(int i = 2; i <= N; ++i)
        sum = (a[i] + sum) / 2;
    cout << fixed << setprecision(5) << sum;
    return 0;
}


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

using namespace std;

int N;
vector<int> item;

int main() {
	cin >> N;

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		item.push_back(tmp);
	}

	sort(item.begin(), item.end(), greater<int>());

	int sum = item[0] / 2;

	for (int i = 1; i < N; i++)sum += item[i];

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  char a;
  cin >> a;
  int p = a - 'a';
  //cout << p << endl;
  if (p < 0) {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int D[10];
bool check(int a,int k){
    int dig;
    bool flag = true;
    while(1){
        if(a==0) break;
        dig = a%10;
        a = a/10;
        for(int i=0;i<k;i++){
            if(dig == D[i]){
                flag = false;
            }
        }
    }
    return flag; 
}
int main(){
    int N,K;
    cin >> N >> K;
    for(int i=0;i<K;i++){
        cin >> D[i];
    }
    for(int i=N;;i++){
        if(check(i,K)){
            cout << i << endl;
            return 0;
        }
    }
}



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

long long digits(long long x) {
  long long ans = 0;
  while(x) {
    ans++; x/=10;
  }
  return ans;
}

int main () {
  long long n; cin >> n;
  long long ans = digits(n);
  for (long long i = 2; i*i <= n; i++) {
    if (n%i) continue;
    long long b = n/i;
    ans = min(ans, max(digits(i), digits(b)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const double inf=1e9;
typedef long long ll;
typedef pair<ll,ll>pr;
const ll mod=1e9+7;
ll _pow(ll  a,ll b) {
    ll ans=1;
    while(b) {
        if(b&1)
            ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

int main(){
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  int ans=a*b;
  cout<<min(ans,c)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  if(A > B){
    cout << 2 * A - 1 << endl;
  }
  else if(A < B){
    cout << 2 * B - 1 << endl;
  }
  else{
    cout << A + B << endl;
  }
  
  
}


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

for cy in range(101):
	for cx in range(101):
		ch = None
		for x, y, h in XYH:
			if 0 == h:
				continue
			dy, dx = abs(y - cy), abs(x - cx)
			ch = h + dy + dx
		if all([h == max(0, ch - abs(y - cy) - abs(x - cx)) for x, y, h in XYH]):
			print(cx, cy, ch)
			exit()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
int A[100001];
int partition(int p, int r){
	int x = A[r];
	int i = p - 1;
	for (int j = p; j <= r - 1; ++j){
		if (A[j] <= x)  swap(A[++i], A[j]);
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}
int main(){
	int n; scanf("%d",&n);
	for (int i = 0; i < n; ++i) scanf("%d",&A[i]);
	int pivot = partition(0, n - 1);
	for (int i = 0; i < n; ++i){
		if (i != 0) cout << ' ';
		if (i == pivot){
			cout << '[' << A[i] << ']';
		}
		else cout << A[i];
	}
	cout << '\n';
}

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

typedef pair<int, int> P;

int n, m;
const int N_MAX = 100005;
const int INF = 1000000005;

vector<P> BOMB;
vector<P> G[N_MAX];
int X[N_MAX];

int used[N_MAX];
vector<int> ANS;
int dfs(int k){
    used[k] = 1;
    int r = X[k];
    for(auto e: G[k]){
        if (used[e.first])continue;
        int res = dfs(e.first);
        if (res){
            ANS.push_back(e.second);
            r ^= res;
        }
    }
    return r;
}


int main(){
    cin >> n >> m;
    BOMB.resize(n+2);
    BOMB[0] = make_pair(0, 0);
    BOMB[n+1] = make_pair(INF, 0);
    for(int i = 1; i <= n; i++){
        cin >> BOMB[i].first >> BOMB[i].second;
    }
    sort(BOMB.begin(), BOMB.end());
    for(int i = 1; i <= n+1; i++)X[i] = BOMB[i].second ^ BOMB[i-1].second;
    for(int j = 1; j <= m; j++){
        int l, r;
        cin >> l >> r;
        l = lower_bound(BOMB.begin(), BOMB.end(), P(l, 0)) - BOMB.begin();
        r = upper_bound(BOMB.begin(), BOMB.end(), P(r, 1)) - BOMB.begin();
        G[l].emplace_back(r, j);
        G[r].emplace_back(l, j);
    }

    memset(used, 0, sizeof(used));
    for(int i = 1; i <= n; i++){
        if (used[i])continue;
        if (dfs(i)){
            cout << -1 << endl;
            return 0;
        }
    }

    sort(ANS.begin(), ANS.end());
    cout << ANS.size() << endl;
    for(auto a: ANS)cout << a << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 15484
s = int(input())
k = int(input())
li = [int(k) for k in list(str(s))]
#print(li)
count = 0
for i in li:
  if i ==1:
    count+=1
  else:
    ans = i
    break
    
if k <= count:
  print(1)
else:
  print(ans)

Measured memory_bytes: 3060
import sys
# import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
stdin = sys.stdin

def gcd(a,b):
  while b:a,b=b,a%b
  return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(l):
    return reduce(lcm, l, 1)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M = i_l()
a = i_l()
half_lcm = lcm_list(a) // 2

for i in a:
    if half_lcm // (i // 2) % 2 == 0:
        print(0)
        exit()

print(((M // half_lcm) + 1) // 2)

Measured memory_bytes: 14860
#include<iostream>
#include<string>
#include<cstdio>

int main(){
    using namespace std;

    string W;
    string T;
    int counts=0;
    cin>>W;

    for(;;){
        cin>>T;
        if(T=="END_OF_TEXT"){
            break;
        }
        for(int i=0;i<T.size();i++){
            if(T[i]>=65&&T[i]<=90){
                T[i]+=32;
            }
        }
        if(W==T){
            counts+=1;
        }
    }

    cout<<counts<<endl;
    return 0;

}





Measured memory_bytes: 3180
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = (int)s.size();
    int ans = 0;
    REP(i,l/2){
        if(s[i]!=s[l-1-i]){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
char s[125252], t[125252];

int main(){
  scanf("%d%d",&n,&m);
  scanf("%s%s",s,t);
  // l = k*lcm(n,m) = k*n*m/gcd(n,m)
  // l/n = k*m/gcd(n,m)
  // l/m = k*n/gcd(n,m)
  // a*(l/n) == b*(l/m)
  // a*k*m == b*k*n
  // a*m == b*n
  // a*(m/gcd(n,m)) == b*(n/gcd(n,m))

  // s = abcd
  // t = efghij
  // 4a = 6b
  // 2a = 3b
  // a??b??c??d??
  // e?f?g?h?i?j?
  int g = __gcd(n,m);
  int m2 = m/g;
  int n2 = n/g;
  int a = 0, b = 0;
  while(a<n && b<m){
    if(s[a]!=t[b]){
      puts("-1");
      return 0;
    }
    a += n2;
    b += m2;
  }
  printf("%lld\n",(ll)n*m/g);
  return 0;
}


Measured memory_bytes: 384
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w

  def initialize
    @n = gets.to_s.to_i
    @a = Array.new(n-1){ gets.to_s.split.map{ |v| v.to_i } }
  end

  def solve
    ans = []
    (n-1).times do |i|
      c,s,f = @a[i]
      cnt = s
      i.upto(n-2) do |j|
        cnt += arrive(j, cnt)
      end
      ans << cnt
    end
    ans << 0
    ans
  end

  # i番目の駅にt秒に到着した後次の駅に到着する時間
  def arrive(i,t)
    c,s,f = @a[i]
    wait(i,t) + c
  end

  # i番目の駅にt秒に到着したとき何秒待つか
  def wait(i,t)
    c,s,f = @a[i]
    return s - t if t <= s
    return 0 if (t - s) % f == 0
    return f - (t - s) % f
  end

  def show(ans)
    puts ans.join("\n")
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14184
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <iomanip>

using namespace std;
using ll = long long;
const int BIG = 100000007;



int main(){
    ll n;
    cin >> n;
    unordered_map<ll,ll> countMap;
    ll n2 = n;
    ll k = 2;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    while (n2 > 1){
        if(n2 % k == 0){
            ++countMap[k];
            n2 /= k;
        }
        else if(k > 1000000){
            ++countMap[n2];
            n2 = 1;
        }
        else{
            if(k == 2)k = 3;
            else k += 2;
        }
    }


    for(auto p = countMap.begin();p != countMap.end();++p){
     //   cout << (*p).first << ":"  << (*p).second << endl;
    }

    int c = 0;

    int o = 1;
    while(countMap.size() > 0){
        unordered_map<ll,ll> newCount;
        for(auto p = countMap.begin();p != countMap.end();++p){
            ++c;
            if((*p).second > o * 2){
                newCount[(*p).first] = (*p).second - o;
            }

        }
        countMap = newCount;
        ++o;
    }

    cout << c << endl;
}


Measured memory_bytes: 3264
#include<iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include <functional>
using namespace std;

int main(void) {
	int A,B,C = 0, ans = 0;
	cin >> A>>B>>C;
	cout << (int)(((double)(C+0.5)/A))*B << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define    ll      long long int
#define    Fori(a,b) for (ll i = a ; i<b ;i++ )
#define    Forj(a,b) for (ll j = a ; j<b ;j++ )
#define    Fork(a,b) for (ll k = a ; k<b ;k++ )
#define    W       while
#define    pb      push_back
#define    nl      cout<<endl
#define    mod     1000000007
#define    I       cin>>
#define    Out     cout<<
#define    DOD(i)  cout<<setprecision(i)<<fixed<<
#define    XXX     return 0
#define    Fast    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
   Fast;
   ll d,n;I d>>n;
   ll a[n];
   ll sum=0;
   Fori(0,n){
       I a[i];
       sum+=a[i];
   }
   if(sum<=d) cout<<d-sum;
   else cout<<-1;
   XXX;
}




Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int n, k; cin>> n >> k;
    string s; cin>> s;
    int a = s[k-1];
    a += 32;
    s[k-1] = a;
    cout<< s << endl;
}


Measured memory_bytes: 3584
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ESequenceDecomposing {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        multiset<int> m;
        REP(i, N) {
            if (m.empty()) {
                m.insert(A[i]);
                continue;
            }

            auto itr = m.lower_bound(A[i]);
            if (itr == m.begin()) {
                m.insert(A[i]);
            } else {
                itr--;
                m.erase(itr);
                m.insert(A[i]);
            }
        }

        cout << m.size() << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ESequenceDecomposing solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 5760
n = int(input())
a = list(map(int, input().split()))

nums = [0]*n
nums[0] = a[0]
for i in range(1,n): nums[i] = a[i]+nums[i-1]

ans = 0
for i in range(n-1):
  ans += a[i]*(nums[n-1]-nums[i])
  ans %= 10**9+7
print(ans)

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

using namespace std;

int main()
{
    long n,t=0,f=0;
    
    cin>>n;
    
   // while(n/5!=0)
   // {
        t = n/500;
        n = n%500;
        f = n/5;
    //}
    cout<<(t*1000 + f*5);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	 int t = sc.nextInt();
	 int count=0;
	  Set<String> set = new HashSet<String>();
	 while(t-->0){
	     String str= sc.next();
	    
	     set.add(str);
	 
}
 for(String stock : set){
   count++;
}
System.out.println(count);
	 
	}
}

Measured memory_bytes: 76916
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <map>
using namespace std;
string t;

int main()
{
    int n,mai=0;
    map<string, int> tic;
    cin >> n;
    for (int i = 0; i < n;i++)
    {
        cin >> t;
        tic[t]++;
        if(tic[t]>mai)
            mai = tic[t];
    }
    for(auto i:tic)
        if(i.second==mai)
            cout << i.first << endl;

    //system("pause");
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
typedef long long ll;
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
long long modpow(long long a,long long n,long long p)
{
    if(n==1)
    {
        return a%p;
    }
    if(n%2==1)
    {
        return a*modpow(a,n-1,p)%p;
    }
    long long t = modpow(a,n/2,p);
    return t*t%p;
}


int main()
{
    int a,b;
    cin>>a>>b;

    if(a<=5)
    {
        cout<<0<<endl;
    }
    else if(a>=13)
    {
        cout<<b<<endl;
    }
    else
    {
        cout<<b/2<<endl;
    }
    


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false)cerr
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;

inline void solve()
{
    int n;
    cin >> n;
    cout << (n / 1000 + (n % 1000 != 0))*1000 - n;
}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

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

int main()
{
    long long n;
    long long cnt = 0;
    cin >> n;

    for (long long i = 1; i < n; i++) {
        for (long long j = 1; j < n; j++) {
            if (i * j > n) break;
            for (long long k = n - i * j; k >= 1; k -= i) {
                if (i * j + k < n) break;
                if (i * j + k == n) {
                    cnt++;
                    // cout << i << " " << j << " " << k << endl;
                    break;
                }
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;
int main() {
	long long n, t, a;
	cin >> n >> t >> a;
	
	t *= 1000;
	a *= 1000;
	long long result = 0, count = 10000000000;
	for (long long i = 0; i < n; ++i) {
		long long h;
		cin >> h;
		
		h = (t - (h * 6)) - a;
		if (h < 0)
			h *= -1;
		
		if (count > h) {
			count = h;
			result = i + 1;
		}
	}

	cout << result << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define REPN(i,n) for(int(i)=1;(i)<(int)(n);(i)++)
#define _abs(x) ((x)>0?(x):-(x))
#define ll  long long 
using namespace std;   
int main()
{
    int n,x,sum=0,s=0;
    cin>>n>>x;
    int l[n];
    REP(i,n)
    {
        cin>>l[i];
        sum+=l[i];
        if(sum<=x)
        {
                s++;
        }
                
    }
    cout<<s+1<<endl;
   // system("pause");
    return 0;
} 

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

typedef long long ll;
 
const int INF= 1001001001;
const ll LINF= 1e18;

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	int min_b = *min_element(b.begin(),b.end());
	int max_a = *max_element(a.begin(),a.end());
	int ans = 0;
	vector<pair<int,int>> p(n);
	for(int i = 0; i < n; i++){
		p[i] = make_pair(min_b-a[i]+1,b[i]-max_a+1);
	}
	sort(p.begin(),p.end());
	int m2 = 1e9;
	for(int i = 0; i < n-1; i++){
		m2 = min(m2,p[i].second);
		ans = max(ans,p[i+1].first + m2);
	}
	for(int i = 0; i < n; i++){
		int cur = b[i] - a[i] + 1;
		cur += max(0,min_b - max_a + 1);
		ans = max(ans,cur);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
    int i,pa,pz,n;
    char s[200000],a = 'A',z = 'Z';
    
    scanf("%s",s);
    for(i = 0; s[i] != '\0'; i++);
    n = i;
    pz = n;
    for(i = 0; i < n; i++){
        if(s[i] == a){
        pa = i;
        break;
        }
    }
    for(i = n;i > 0;i--){
        if(s[i] == z){
            pz = i;
            break;
        }
    }
    n = pz - pa + 1;

    printf("%d",n);
    
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
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;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

// 二項係数計算
long long COM(ull n, ull k){
    return n*(n-1)/2;
}

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ull n;cin>>n;
    vector<ull>a(n);
    map<ull,ull>m;
    for(ull i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    ull total=0;
    for(ull i=1;i<=n;i++){
        if(m[i])total+=COM(m[i],2);
    }

    for(ull k=1;k<=n;k++){
        ull tmp=total;
        if(m[a[k-1]]>=2){
            tmp-=COM(m[a[k-1]],2);
            tmp+=COM(m[a[k-1]]-1,2);
        }
        cout<<tmp<<endl;
    }

    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


Measured memory_bytes: 16664
#include <bits/stdc++.h>
#define INF 100
using namespace std;
const int w = 15;
const int h = 19;
typedef pair<int,int> P;
vector<string> mp(h);
map<P,int>M;
bool inmp(int x,int y){return 0<=x&&0<=y&&x<w&&y<h;}
bool goal(int x,int y){return (y==h||(y==h-1&&0<=x&&x<w));}

int mem[1<<20],used[1<<20];
int dfs(int x,int y,int bit){
  if(goal(x,y)) return 0;
  if(!inmp(x,y)) return INF;
  if(used[bit]++) return mem[bit];
  
  int res = INF;
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++){
      int nx = x+i;
      int ny = y+j;
      int nbit = bit;
      if(!inmp(nx,ny)||mp[ny][nx] != 'X') continue;

      vector<string>tmp = mp;
      while(inmp(nx,ny)&&mp[ny][nx]=='X'){
	mp[ny][nx] = '.';
	nbit |=1<<M[P(nx,ny)];
	nx+=i,ny+=j;
      }
      res=min(res,1+dfs(nx,ny,nbit));
      mp = tmp;
    }
  return mem[bit]=res;
}

int main(){

  for(int i=0;i<h;i++)cin>>mp[i];

  for(int i=0,c=0;i<h;i++)
    for(int j=0;j<w;j++) if(mp[i][j]=='X') M[P(j,i)] = c++;

  int ans; 
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) if(mp[i][j] =='O') ans=dfs(j,i,0);

  cout<<(ans<INF? ans:-1)<<endl;
  return 0;
}

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

unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
        return 1; 
    return n * factorial(n - 1); 
} 
  

struct point
{
    int x;
    int y;
};

int main()
{
    struct point* points;
    double one_path_result;
    double all_paths_result=0;
    unsigned int i,j,N;
    double visits,repetition;
    double result;

    scanf("%d",&N);
    points = (struct point*)malloc(N*sizeof(struct point));

    for(i=0;i<N;i++)
    {
        scanf("%d%d",&points[i].x,&points[i].y);
    }
    visits = factorial(N);
    repetition = visits/N;

    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            if(i==j)
            {
                continue;
            }
            else
            {
                one_path_result = sqrt( pow( (points[i].x-points[j].x),2) + pow((points[i].y-points[j].y),2));
                all_paths_result += one_path_result;
            }
            
        }
    }
    result = all_paths_result/visits;
    printf("%lf",result*repetition);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int x;
	cin >> x;
	int ans = 1000 * (x / 500);
	x %= 500;
	ans += 5 * (x / 5);
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
n,y = map(int,input().split())
f = False
for a in range(n+1):
    for b in range(n+1):
        c = n-(a+b)
        if 10000*a+5000*b+1000*c == y and a+b+c == n and c>= 0:
            f = True
            print(a,b,c)
    if f == True:
        break
if f == False:
    print('-1 -1 -1')

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 4000 + 100;
int Begin[Maxn], To[Maxn], Next[Maxn], e;
int Sum[Maxn], Dep[Maxn];
int N, K, Maxdep;

inline void add_edge(int x, int y)
{
	To[++e] = y;
	Next[e] = Begin[x];
	Begin[x] = e;
}

inline void dfs (int x, int fa)
{
	Maxdep = max(Maxdep, Dep[x]);
	Sum[Dep[x]] ++;
	for (int i = Begin[x]; i; i = Next[i])
	{
		int y = To[i];
		if (y == fa) continue;
		Dep[y] = Dep[x] + 1;
		dfs(y, x);
	}
}

int main()
{
#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	scanf("%d%d", &N, &K);
	for (int i = 1; i < N; ++i)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		add_edge(x, y);
		add_edge(y, x);
	}
	int Ans = 0x3f3f3f3f;
	for (int i = 1; i <= N; ++i)
	{
		memset(Sum, 0, sizeof(Sum));
		memset(Dep, 0, sizeof(Dep));
		Maxdep = 0;
		dfs(i, 0);
		int Cnt = 0;
		for (int j = K / 2 + 1; j <= Maxdep; ++j)
			Cnt += Sum[j];
		int Maxsize = 0;
		if (!(K & 1))Ans = min(Ans, Cnt);
		else 
		{
			for (int j = Begin[i]; j; j = Next[j])
			{
				int y = To[j];
				int tmp = 0;
				memset(Sum, 0, sizeof(Sum));
				memset(Dep, 0, sizeof(Dep));
				Maxdep = 0;
				dfs(i, y);
				for (int k = K / 2 + 1; k <= Maxdep; ++k)
					tmp += Sum[k];
				memset(Sum, 0, sizeof(Sum));
				memset(Dep, 0, sizeof(Dep));
				Maxdep = 0;
				dfs(y, i);
				for (int k = K / 2 + 1; k <= Maxdep; ++k)
					tmp += Sum[k];
				Ans = min(Ans, tmp);
			}
		}
	}
	cout<<Ans<<endl;
	return 0;
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

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

    string s;
    cin >> s;
    int A = 0;
    int B = 0;
    if(s[0] == 'A') A++;
    if(s[0] == 'B') B++;
    if(s[1] == 'A') A++;
    if(s[1] == 'B') B++;
    if(s[2] == 'A') A++;
    if(s[2] == 'B') B++;
    if(A == 0 || B == 0) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
void clear(int *arr) {
  for (int i = 0; i < 1001; i++) arr[i] = 0;
}
int main() {
  int n,arr[1001];
  double ave, l = 0;
  while (true) {
    scanf("%d", &n);
    if (n == 0) break;
    clear(arr);
    l = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &arr[i]);
      l += arr[i];
    }
    ave = l/n;
    l = 0;
    for (int j = 0; j < n; j++) {
      l += pow(arr[j] - ave, 2.0);
    }
    l /= n;
    printf("%lf\n", sqrt(l));
  }
  return 0;
}



Measured memory_bytes: 2736