akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

ll nd(ll x){
  ll c = 0;
  rep(i, x){
    if(x % (i+1) == 0){
      c++;
    }
  }
  return c;
}

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  rep(i, (N+1)/2){
    if(nd(2*i+1) == 8){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <memory.h>
#include <deque>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const int M=100005;
const int N=1000001;
const int K=1000000009;
const ll MAX=1000000000000000000ll;
int n,m,dp[M];
vector<vector<int> >v;
int dfs(int x)
{
	dp[x]=0;
	for(int i=0;i<v[x].size();i++)
		if(dp[v[x][i]]==-1)
			dp[x]=max(dp[x],dfs(v[x][i])+1);
		else
			dp[x]=max(dp[x],dp[v[x][i]]+1);
	return dp[x];
}
int main(){
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    v.resize(n+1);
    for(int i=0,x,y;i<m;i++)
    {
    	scanf("%d%d",&x,&y);
    	v[x].push_back(y);
    }
    for(int i=1;i<=n;i++)
    	if(dp[i]==-1)
    		dfs(i);
    int mx=0;
    for(int i=1;i<=n;i++)
    	mx=max(mx,dp[i]);
    cout<<mx;
}

Measured memory_bytes: 7424
from collections import deque, defaultdict
N, Q = map(int, input().split())
G = defaultdict(lambda: deque())
for _ in range(N-1):
    a,b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
   
cnt = [0]*(N+1)
for _ in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

def dfs(v, cnt):
    seen = [0] * (N+1)
    seen[v] = 1
    stack = [v]
    while stack:
        v = stack[-1]
        if G[v]:
            w = G[v].popleft()
            if not seen[w]: # if 訪れていなければ
                cnt[w] += cnt[v]
                seen[w] = 1
                stack.append(w)
        else:
            stack.pop()
    return cnt

cnt = dfs(1, cnt)
print(*cnt[1:])

Measured memory_bytes: 239840
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
class Dice {
	int num[6];
public:
	Dice(int a,int b,int c,int d,int e,int f) {
		num[0] = a; num[1] = b; num[2] = c;
		num[3] = d; num[4] = e; num[5] = f;
	}

	void rotate(char c) {
		assert(c == 'N' || c == 'S' || c == 'E' || c == 'W');
		int memo = num[0];
		if (c == 'N') {
			num[0] = num[1];
			num[1] = num[5];
			num[5] = num[4];
			num[4] = memo;
		}
		else if (c == 'S') {
			num[0] = num[4];
			num[4] = num[5];
			num[5] = num[1];
			num[1] = memo;
		}
		else if (c == 'E') {
			num[0] = num[3];
			num[3] = num[5];
			num[5] = num[2];
			num[2] = memo;
		}
		else {
			num[0] = num[2];
			num[2] = num[5];
			num[5] = num[3];
			num[3] = memo;
		}
	}

	int getNum(int index) { return num[index]; }

	bool operator==(const Dice& dice) {
		rep(i, 6) {
			if (num[i] != dice.num[i])return false;
		}
		return true;
	}
};
int a[6], q, x, y;
string s;
signed main() {
	rep(i, 6)cin >> a[i];
	Dice dice1(a[0], a[1], a[2], a[3], a[4], a[5]);
	rep(i, 6)cin >> a[i];
	Dice dice2(a[0], a[1], a[2], a[3], a[4], a[5]);
	rep(i, 100000) {
		int m = rand() % 2;
		if (m == 0)dice1.rotate('N');
		else dice1.rotate('E');
		if (dice1 == dice2) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


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

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

    ll ans = k * pow(k - 1, n - 1);

    cout << ans << endl;
    return 0;
}


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

using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;++i)
long long N,Y;
long long A=0;
int main()
{
  int a[1000000];
  int c2=0,c4=0,c=0;
  cin>>N;
  REP(i,N)cin>>a[i];
  REP(i,N){
    if(a[i]%4==0){
      c4++;
    }else if(a[i]%2==0){
      c2++;
    }else{
      c++;
    }
  }
  
  if(c2>0){
    if(c<=c4)cout<<"Yes";
    else cout<<"No";
  }else{
    if(c<=c4+1)cout<<"Yes";
    else cout<<"No";
  }
  return 0;
}


Measured memory_bytes: 4028
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n, k, x, y, res = 0;
  cin>>n>>k>>x>>y;
  for(int i = 1; i <= n; i++){
    res += i<=k?x:y;
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {
	int h = -1, w;
	cin >> h >> w;
	vector<string> b(h);
	for (int i = 0; i < h; ++i) {
		cin >> b[i];
	}
	int dp[102][102][2] = {};
	memset(dp, 0x3f, sizeof(dp));
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (b[i][j] == '.') {
				int c = (i == 0 && j == 0) ? 0 : 1 << 30;
				if (i > 0) {
					c = min(c, dp[i - 1][j][0]);
					c = min(c, dp[i - 1][j][1]);
				}
				if (j > 0) {
					c = min(c, dp[i][j - 1][0]);
					c = min(c, dp[i][j - 1][1]);
				}
				dp[i][j][0] = c;
			} else {
				int c = (i == 0 && j == 0) ? 1 : 1 << 30;
				if (i > 0) {
					c = min(c, dp[i - 1][j][0] + 1);
					c = min(c, dp[i - 1][j][1]);
				}
				if (j > 0) {
					c = min(c, dp[i][j - 1][0] + 1);
					c = min(c, dp[i][j - 1][1]);
				}
				dp[i][j][1] = c;
			}
		}
	}
	cout << min(dp[h - 1][w - 1][0], dp[h - 1][w - 1][1]) << endl;
	return 0;
}


Measured memory_bytes: 384
import itertools
n=int(input())
a=[int(i) for i in input().split(" ")]

perms=list(itertools.permutations([i+1 for i in range(n)]))
for i,p in enumerate(perms):
    if list(p)==a:
        break

if i>0:
    print(" ".join([str(j) for j in perms[i-1]]))
print(" ".join([str(j) for j in perms[i]]))
try:
    print(" ".join([str(j) for j in perms[i+1]]))
except IndexError:
    pass



Measured memory_bytes: 52368
import math


def main():
    N = int(input())

    a = int(math.sqrt(2 * N))

    if N != a * (a + 1) / 2:
        print('No')
        return

    k = a + 1
    n = a

    S = [[] for i in range(k)]

    count = 0
    for i in range(k):
        for j in range(i+1, k):
            count += 1
            S[i].append(count)
            S[j].append(count)

    print('Yes')
    print(k)
    for Si in S:
        print(str(n) + ' ' + ' '.join(map(str, Si)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9076
#include <stdio.h>

int
main(
    void
)
{
    char s[4] = {0};
    scanf("%s", s);

    if ( ((s[0] == '0') && (s[1] != '0')) ||
         ((s[0] == '1') && ((s[1] == '1') || (s[1] == '2'))) )
    {
        if ( ((s[2] == '0') && (s[3] != '0')) ||
             ((s[2] == '1') && ((s[3] == '1') || (s[3] == '2'))) )
        {
            printf("AMBIGUOUS\n");
        }
        else
        {
            printf("MMYY\n");
        }
    }
    else
    {
        if ( ((s[2] == '0') && (s[3] != '0')) ||
             ((s[2] == '1') && ((s[3] == '1') || (s[3] == '2'))) )
        {
            printf("YYMM\n");
        }
        else
        {
            printf("NA\n");
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

class Tree {
public:
    int N;
    vector<vector<int>> G;
    vector<int> ans;

    Tree(int N) :N(N) {
        G.resize(N);
        ans.resize(N);
    }

    void add_edge(int s, int t) {
        G[s].push_back(t);
    }

    int dfs(int v) {
        int ret = 0;
        for(int i = 0; i < (int)G[v].size(); i++) {
            ret += dfs(G[v][i]);
        }

        ans[v] = ret;
        return ret + 1;
    }

    void print() {
        for(int i = 0; i < N; i++) {
            cout << ans[i] << endl;
        }
    }
};
/*
int main() {
    int N;
    cin >> N;
    Tree tr = Tree(N);
    for(int i = 0; i < N - 1; i++) {
        int x;
        cin >> x;
        tr.add_edge(x - 1, i + 1);
    }

    int x = tr.dfs(0);
    tr.print();
    return 0;
}*/

int main() {
    int N;
    cin >> N;
    vector<int> cnt(N, 0);
    for(int i = 0; i < N - 1; i++) {
        int x;
        cin >> x;
        cnt[x - 1]++;
    }

    for(int i = 0; i < N; i++) {
        cout << cnt[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4052
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
const ll INF = 1e18+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	vl A(n+1),B(m+1);
	take(A,1,n);
	take(B,1,m);
	for(int i=1;i<=m;i++)
	{
		B[i]+=B[i-1];
	}
	ll curr=0;
	int ma=0;
	for(int i=0;i<=n;i++)
	{
		curr+=A[i];
		if(curr>k) break;
		int low=0,high=m;
		int mab=0;
		while(low<=high)
		{
			int mid=low+(high-low)/2;

			if(B[mid]+curr<=k)
			{
				mab = mid;
				low=mid+1;
			}
			else high=mid-1;
		}
		ma=max(ma,mab+i);
	}
	cout<<ma<<endl;
}		

Measured memory_bytes: 6680
#include <iostream>

using namespace std;
int main (){

	char a[16];
	char b[] = "CODEFESTIVAL2016";
	cin >> a;
	int cnt = 0 ;
	for(int i = 0;i < 16;i++){
		if (a[i] != b[i]){
			cnt++;
		}
	}
cout << cnt << endl;
return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;

 ll mod=1e9 +7;

ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll get_val(vector<ll>&ft,ll index)
{
  ll res=0;
  for(;index>=0;index=(index & (index+1))-1)
    res+=ft[index];
  return res;
}

void update(vector<ll>&ft,ll index,ll val)
{
  for(;index<(ll)ft.size();index|=index+1)
    ft[index]+=val;
}

ll max_sum(vector<ll>&a)
{
  ll n=a.size();
  ll i,cur=0,res=0;
  for(i=0;i<n;i++)
  {
    if(a[i]>=0)
    {
      if(cur>=0) cur+=a[i];
      else cur=a[i];
    } 
    else
    {
      if(cur>=0) cur+=a[i];
      else cur=a[i];
    }
    res=max(res,cur);
  }
  return res;
}

string ans;
ll n,k,upr;

void func(string &cur,ll rem,bool flag,ll minl)
{
  if(rem==0) {ans=min(ans,cur); return;}
  if(ans.length()>0 && cur.length()==ans.length()) return;
  if(cur.length()>=upr) return;
  if(flag)
  {
    for(ll i=0;i<=9;i++)
    {
      ll next=(i+1)%10;
      ll cnt=minl+1;
      if(i*(k+1-cnt) + next*cnt >rem) break;
      cur=to_string(i)+cur;
      bool fg=false;
      if(next==0) fg=true;

      ll val=min(i,next);
      func(cur,rem- (i*(k+1-cnt) + next*cnt),fg,val);
      cur=cur.substr(1,cur.length()-1);
    }
  }
  else
  {
    for(ll i=0;i<=9;i++)
    {
      if((k+1)*i>rem) break;
      cur=to_string(i)+cur;
      func(cur,rem-(k+1)*i,false,-1);
      cur=cur.substr(1,cur.length()-1);
    }
  }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //   #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    
    // Sieve();
   ll tests=1;
 // cin>>tests;
  // ll t=1;
    while(tests--)
    {  
      ll n,i;
      ll ans=0;
      string s,t;
      cin>>s>>t;
      n=s.length();
      for(i=0;i<n;i++)
      {
        if(s[i]!=t[i]) ans++;
      }
      cout<<ans;


    }

    return 0;
   }

Measured memory_bytes: 14792
s = input()
if 1<= int(s[:2]) <= 12  and 1 <= int(s[2:]) <= 12:
    print("AMBIGUOUS")
elif 1<= int(s[:2]) <= 12:
    print("MMYY")
elif 1<= int(s[2:]) <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void babbleSort(int *a,int n){
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(a[j]>=a[j-1]){
				swap(&a[j],&a[j-1]);
			}
		}
	}
}

int main(){

	int n;

	while(cin>>n){
		if(n==0)break;
		int *a;
		a = new int[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}

		babbleSort(a,n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=a[i];
		}
		cout<<sum/(n-2)<<endl;
	}

	return 0;
}

Measured memory_bytes: 1188
N = int(input())

row_1 = [int(i) for i in input().split()]
row_2 = [int(i) for i in input().split()]

candies = []
for i in range(1,N+1):
    candies.append(sum(row_1[:i]) + sum(row_2[i-1:]))

print(max(candies))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main()
{
  int N;
  cin >> N;
  int each_len = 0, num_group = 0, num_part;
  num_part = N * 2;
  for (int i = 1; i * (i - 1) < num_part + 1; ++i)
  {
    if (i * (i - 1) == num_part)
    {
      num_group = i;
      break;
    }
  }
  if (num_group == 0)
  {
    cout << "No" << endl;
    return 0;
  }
  each_len = num_part / num_group;
  vector<vector<int>> graph(each_len);
  int cnt = 1;
  // cout << each_len << ' ' << num_part << ' ' << num_group << endl;
  for (int i = 0; i < each_len; ++i)
  {
    for (int j = 0; j < i + 1; ++j)
    {
      graph.at(i).push_back(cnt);
      cnt += 1;
    }
  }
  //
  vector<vector<int>> ans;
  for (int i = 0; i < each_len; ++i)
  {
    int h = i;
    int w = i;
    vector<int> temp = graph.at(h);
    for (int j = i + 1; j < each_len; ++j)
    {
      temp.push_back(graph.at(j).at(w));
    }
    ans.push_back(temp);
  }
  vector<int> temp;
  for (int i = 0; i < each_len; ++i)
  {
    temp.push_back(graph.at(i).at(i));
  }
  ans.push_back(temp);
  //
  cout << "Yes" << endl;
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i)
  {
    cout << each_len << ' ';
    for (int j = 0; j < each_len; ++j)
    {
      cout << ans.at(i).at(j) << ' ';
    }
    cout << endl;
  }
  // for (int i = 0; i < each_len; ++i)
  // {
  //   for (int j = 0; j < graph.at(i).size(); ++j)
  //   {
  //     cout << graph.at(i).at(j) << ' ';
  //   }
  //   cout << endl;
  // }
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int i, j, n, len, num = 0;
    char search[11], str[21];
     
    scanf("%s", search);
    scanf("%d", &n);
     
    for (i = 0; i < n; i++){
        scanf("%s", str);
         
        len = strlen(str);
        strcat(str, str);
         
        for (j = 0; j < len; j++){
            if (strncmp(&str[j], search, strlen(search)) == 0){
                num++;
                break;
            }
        }
    }
     
    printf("%d\n", num);
     
    return (0);
}


Measured memory_bytes: 2036
#include <stdio.h>
#define Nmax 1500
#define Mmax 1500
#define INF 1000000

int main (void){
    int N, M;
    int i,j;
    int h[Nmax]={},w[Mmax]={};
    int counth[INF], countw[INF];
    int tmp;
    int sum;
 
    while(1){
        //テ・ツ按敕ヲツ慊淌・ツ個?
        for(i=0;i<Nmax;i++)
            h[i]=0;
        for(i=0;i<Mmax;i++)
            w[i]=0;
        for(i=0;i<INF;i++)
            counth[i]=0;
        for(i=0;i<INF;i++)
            countw[i]=0;
        sum = 0;
        //テ・ツ?・テ・ツ環?
        scanf("%d %d", &N, &M);
        if(!N && !M)
            break;
        for(i=0;i<N;i++)
            scanf("%d",&h[i]);
        for(i=0;i<M;i++)
            scanf("%d",&w[i]);
        //テ・ツ?ヲテァツ青?
        for(i=0;i<N;i++){
            tmp=0;
            for(j=i;j<N;j++){
                tmp += h[j];
                counth[tmp]++;
            }
        }
        for(i=0;i<M;i++){
            tmp=0;
            for(j=i;j<M;j++){
                tmp += w[j];
                countw[tmp]++;
            }
        }
        //テ・ツ?コテ・ツ環?
        for(i=0;i<INF;i++){
            sum += (counth[i] * countw[i]);
        }
        printf("%d\n",sum);
    }
    
    return 0;
}

Measured memory_bytes: 8424
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9+7

N = int(input())
A = [Fraction(input())*10**9 for _ in range(N)]

d = defaultdict(int)

for i in range(N):
    n = A[i]
    c2 = 0
    while n%2 == 0:
        n //= 2
        c2 += 1

    n = A[i]
    c5 = 0
    while n%5 == 0:
        n //= 5
        c5 += 1

    c2 = min(c2,18)
    c5 = min(c5,18)

    d[(c2,c5)] += 1

ans = 0
for k2,k5 in d.keys():
    for l2,l5 in d.keys():
        if k2 + l2 >= 18 and k5 + l5 >= 18:
            if k2 == l2 and k5 == l5:
                ans += d[(k2,k5)]*(d[(k2,k5)]-1)
            else:
                ans += d[(k2,k5)]*d[(l2,l5)]

print(ans//2)

Measured memory_bytes: 116116
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.StringTokenizer;

public class Main {
	
	public static long gcd(long a, long b){
		return b == 0 ? a : gcd(b, a % b);
	}
	public static long lcm(long a, long b){
		return a / gcd(a, b) * b;
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final long A = sc.nextLong();
			final long B = sc.nextLong();
			final long C = sc.nextLong();
			final long D = sc.nextLong();
			
			final long UPPER = B - ((B / C) + (B / D) - (B / lcm(C, D)));
			final long LOWER = (A - 1) - (((A - 1) / C) + ((A - 1) / D) - ((A - 1) / lcm(C, D)));
			
			System.out.println(UPPER - LOWER);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21332
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << "[" << e << "] ";
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N, A, B;
	cin >> N >> A >> B;

	vector<lint> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	sort(h.begin(), h.end());

	auto biSearch = [&](auto &f) {
		lint ng = -1;
		lint ok = h.back();

		while (abs(ok - ng) > 1) {
			lint mid = (ok + ng) / 2;

			if (f(mid)) ok = mid;
			else ng = mid;
		}

		return ok;
	};

	auto judge = [&](int idx) {

		lint ex = 0;
		for (int i = 0; i < N; i++) {
			if (h[i] - B * idx > 0) ex += (h[i] - B * idx - 1) / (A - B) + 1;
			DMP(ex);
		}

		DMP(idx, ex);
		return ex <= idx;

	};

	cout << biSearch(judge) << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
  unordered_map<long int, long int>um;
  ordered_set s;

  long int n;
  cin>>n;
  

  long int q; 
  cin>>q;


  vector<long int>a(n);
  for (auto &ele : a)
    cin>>ele;
  
  
  vector<long int>ans(q);
  vector<vector<pair<long int, long int>>>que(n);
  
  for (int i = 0; i < q; i++){
    long int L, R; 
    cin>>L>>R;
    L--;
    R--;
    
    que[R].push_back({L, i});
  }

  for (long int i = 0; i < n; i++){
    if (um.count(a[i]))
      s.erase(um[a[i]]);
    
    um[a[i]] = i;
    s.insert(i);
    
    for (auto it : que[i])
      ans[it.second] = s.size() - s.order_of_key(it.first);
  }
  for (int i = 0; i < q; i++)
    cout << ans[i] << "\n";
  
   return 0;
}

Measured memory_bytes: 87448
#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
using namespace std;

stack<int> T; //??¨????¨?????????????
stack<pair<int,int>> R;

vector<int> r;
int main() {
    char str[20001];
    cin>>str;
    int result=0;
    bool completed=false;
    for(int i=0;i<strlen(str);i++)
    {
        if(str[i]=='\\') //??\???
        {
            T.push(i);
        }
        else if(str[i]=='/'&&!T.empty()) //???????????????
        {
            int x=T.top(); T.pop();
            int a=i-x;
            //R.push(make_pair(x,current_areas));
            //int a=0;
            while(!R.empty()&&R.top().first>x)
            {
                a+=R.top().second; R.pop();
            }
            if(a)
               R.push(make_pair(x,a)); //?????°??\???
        }

    }
    int sum=0;
    while(!R.empty())
    {
        sum+=R.top().second;
        r.push_back(R.top().second); R.pop();
    }
    cout<<sum<<endl;
    cout<<r.size();
    for(int i=r.size()-1;i>=0;i--)
        cout<<' '<<r[i];
    cout<<endl;
}

Measured memory_bytes: 3260
#include <iostream>
#define lli long long int

using namespace std;

int main()
{
  lli n, m, s, t, u, v;

  while(cin>>n && n){
    cin >> m;
    if(n%2 == 0){
      v = n/2;
    } else {
      v = (n+1)/2;
    }

    while(m--){
      cin >> s >> t;
      if(s > v){
	s = n - s + 1;
      }
      if(t > v){
	t = n - t + 1;
      }

      if(s < t){
	u = s;
      } else {
	u = t;
      }
      u = (u-1) % 3;
      cout << (u+1) << endl;
    }
  }

  return 0;
}

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

int abs(int a){
	return a < 0 ? (-a) : a;
}

int main(void){
	int n;
	int *w;
	int right = 0, left = 0;
	scanf("%d", &n);
	w = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i ++){
		scanf("%d", w + i);
		right += w[i];
	}
	int min = right;
	for(int i = 0; i < n; i++){
		left += w[i];
		right -= w[i];
		if(min > abs(right - left)){
			min = abs(right - left);
		}
	}
	printf("%d\n", min);
	return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c,x; cin >> a >> b >> c >> x;
  int ans = 0;

  for(int i = 0;i<=a;i++)
    for(int j = 0;j<=b;j++)
      for(int k = 0;k<=c;k++)
    if(500*i+100*j+50*k==x) ans++;

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3596
N = int(input())
*W, = map(int, input().split())

front = W[0]
back = sum(W) - W[0]
diff = abs(front - back)
for i in range(1, N):
  front += W[i]
  back -= W[i]
  diff = min(diff, abs(front - back))

print(diff)
  


Measured memory_bytes: 38384
#pragma GCC optimize ("Ofast")
#pragma GCC target ("tune=native")

#include <bits/stdc++.h>

using namespace std;

int N, res = 0;

vector<int> h;

void solve(int beginning, int ending) {
    if (*max_element(h.begin() + beginning, h.begin() + ending) == 0) return;
    int mini = *min_element(h.begin() + beginning, h.begin() + ending);
    for (auto it = h.begin() + beginning; it != h.begin() + ending; it++) {
	*it -= mini;
    }
    res += mini;
    int newbegin = -1;
    for (auto it = h.begin() + beginning; ; it++) {
	if (it == h.begin() + ending) {
	    if (newbegin != -1) {
		solve(newbegin, ending);
	    }
	    break;
	}
	if (*it != 0 && newbegin == -1) {
	    newbegin = it - h.begin();
	}
	if (*it == 0 && newbegin != -1) {
	    solve(newbegin, it - h.begin());
	    newbegin = -1;
	}
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    h.resize(N);
    for (auto& i : h) cin >> i;
    solve(0, N);
    cout << res;
    return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var set1 = new HashSet<string>();
            int N = int.Parse(Console.ReadLine());
            string[] vs = new string[N];
            int count=0;
            for(int i = 0; i < N; i++)
            {
                set1.Add(Console.ReadLine());
            }
            var lst = set1.ToList();
            count = lst.Count;
            Console.WriteLine("{0}", count);
        }
    }
}


Measured memory_bytes: 47712
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main()	{

	int n, q, m, d;
	vector<int>::iterator itr;
	vector<int> conv(100);

	while (true)	{

		scanf("%d %d", &n, &q);
		if (n == 0)	break;

		for (int i = 0; i <= 99; i++)	{
			conv[i] = 0;
		}

		for (int i = 0; i <= n-1; i++)	{

			cin >> m;

			if (m == 0)	{
				continue;
			}

			for (int j = 0; j <= m-1; j++)	{

				cin >> d;

				conv[d]++;
			}
		}

		for (int i = n; i >= q; i--)	{
			itr = find(conv.begin(), conv.end(), i);
			if (itr != conv.end())	{
				break;
			}
		}

		if (itr == conv.end())	{
			printf("0\n");
		} else	{
			cout << itr - conv.begin() << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3128
S = input()
pre = int(S[:2])
post = int(S[2:])
preM = pre > 0 and pre < 13
postM = post > 0 and post < 13
if preM and postM:
  print('AMBIGUOUS')
elif preM:
  print('MMYY')
elif postM:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int a, b, c;
    int pay[3];
    cin >> pay[0] >> pay[1] >> pay[2];

    sort(pay, pay+3, greater<int>());
    // sort(pay, pay+3, [](const int a, const int b) {return a > b;});

    cout << pay[0]*10 + pay[1] + pay[2] << endl;

    return 0;
}

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

const ll mod=1e9+7;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	ll res=1;
	for(int i=1;i<=n;++i)
		res=res*1LL*i%mod;
	cout<<res<<'\n';
}




Measured memory_bytes: 3644
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


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


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
tmp = [0]*4
for _ in range(n):
    s = input()
    if s == 'AC':
        tmp[0] += 1
    if s == 'WA':
        tmp[1] += 1
    if s == 'TLE':
        tmp[2] += 1
    if s == 'RE':
        tmp[3] += 1

print('AC', 'x', tmp[0],)
print('WA', 'x', tmp[1],)
print('TLE', 'x', tmp[2],)
print('RE', 'x', tmp[3],)


Measured memory_bytes: 74812
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int n;
const int possible_a=1e6+7;
int main(){
    cin >> n;
    vector<int> v; v.resize(n);
    vector<int> dp(possible_a, 0);
    for(int i=0; i<n; i++) cin >> v[i];
    int max_a = *max_element(v.begin(), v.end());
    for(auto i : v){
        for(int j=i; j<=max_a; j+=i){
            if(j==i) dp[j] += 1;
            else dp[j] += 2;
        }
    }
    int count = 0;
    for(auto i : v) if(dp[i]==1) count++;
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 7920
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;

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

int main() {
	int R;
	cin >> R;
	if (R < 1200)cout << "ABC" << endl;
	else if (R >= 2800)cout << "AGC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int N, M, X; cin >> N >> M >> X;
    vector<int> A(M);
    rep(i,M)  cin >> A[i];
    int now = X-1;
    int cost_0 = 0, cost_N = 0;
    while(now>=0){
      if(vector_finder(A, now)) cost_0++;
      now--;
    }
    now = X+1;
    while(now<=N){
      if(vector_finder(A, now)) cost_N++;
      now++;
    }

    cout << min(cost_0, cost_N) << endl;
    return 0;
}


Measured memory_bytes: 256
def show (nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else :
            print(nums[i])

n=int(input())
nums=list(map(int,input().split()))
show(nums)
for i in range(1,n):
    v=nums[i]
    j=i-1
    while (j>=0 and nums[j]>v):
        nums[j+1]=nums[j]
        j-=1
    nums[j+1]=v
    show(nums)


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

int main()
{
	int a,b;
	int sum ,j,c;
	cin>>a>>b;
	sum=a+b;
	c=a-b;
	j=a*b;
	int ans=max(sum,j);
	ans=max(ans,c);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll ABCD) {
  ll a = ABCD / 1000;
  ll b = (ABCD / 100) % 10;
  ll c = (ABCD / 10) % 10;
  ll d = (ABCD % 10);

  string result;
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> s(tmp);

    ll v;
    v = s.test(2) ? a + b : a - b;
    v += s.test(1) ? c : -c;
    v += s.test(0) ? d : -d;
    if (v == 7) {
      string op1 = s.test(2) ? "+" : "-";
      string op2 = s.test(1) ? "+" : "-";
      string op3 = s.test(0) ? "+" : "-";
      result = to_string(a) + op1 + to_string(b) + op2 + to_string(c) + op3 +
               to_string(d) + "=7";
      break;
    }
  }

  cout << result << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll ABCD;
  scanf("%lld", &ABCD);
  solve(ABCD);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(5)
       << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) << '\n';
}



Measured memory_bytes: 3256
# AOJ ITP1_10_D

import math

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    n = int(input())
    x = intinput()
    y = intinput()
    sum_1 = 0
    sum_2 = 0
    sum_3 = 0
    MD_INFTY = 0
    for i in range(n):
        MD_INFTY = max(MD_INFTY, abs(x[i] - y[i]))
        sum_1 += abs(x[i] - y[i])
        sum_2 += abs(x[i] - y[i]) ** 2
        sum_3 += abs(x[i] - y[i]) ** 3
    MD_1 = sum_1
    MD_2 = math.sqrt(sum_2)
    MD_3 = sum_3 ** (1 / 3)
    print(MD_1); print(MD_2); print(MD_3); print(float(MD_INFTY))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5696
#include <stdio.h>

int main(void)
{
  int a, b, c, i, count;

  count = 0;
  scanf("%d %d %d", &a, &b, &c);

  for (i=a; i < b+1; i++){
    if (!(c%i))
      count += 1;
  }

  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int cnt = 0;
    while(cin >> s) {
        if (cnt) cout << " "; cnt++;
        REP(i, s.size()) {
            if ('a' <= s[i] && s[i] <= 'z' ){
                s[i] += ('A' - 'a');
            } else if ('A' <= s[i] && s[i] <= 'Z') {
                s[i] += ('a' - 'A');
            }
        }
        cout << s;
    }
    cout << endl;
    return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n,w;
	cin>>n>>w;
	vector<P> item(n);
	rep(i,n)cin>>item[i].first>>item[i].second;
	int sup_value = n*1000+1;
	vector<vector<ll>> dp(n+1,vector<ll>(sup_value, INF+10));
	dp[0][0]=0;

	rep(i,n){
		repr(j, sup_value-1, 0){
			if(j-item[i].second<0) dp[i+1][j] = dp[i][j];
			else dp[i+1][j] = min(dp[i][j], dp[i][j-item[i].second]+item[i].first);
		}
	}
	int ans=0;
	rep(i,sup_value){
		if(dp[n][i]<=w)ans=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int MIN(int x1,int x2,int x3,int x4,int x5,int x6)
{
    return min(x1,min(x2,min(x3,min(x4,min(x5,x6)))));
}
int main()
{
  int AB,BC,CA;
  cin>>AB>>BC>>CA;
  cout<<MIN(AB+BC,CA+BC,AB+CA,BC+CA,CA+AB,BC+AB);
  
    return 0;
    
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main() {
    int n, m; cin >> n >> m; vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }int ans = 0;
    rep(i, m) {
        UnionFind tree(n); bool boo = false;
        rep(j, m) {
            if (i == j)continue;
            tree.unite(a[j], b[j]);
        }
        rep(j, n) {
            rep(k, n) {
                if (!tree.same(k, j)) {
                    ans++; boo = true;
                    break;
                }
            }if (boo)break;
        }
    }cout << ans << endl;
}

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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx, dy = ty - sy;
    for (int i = 0; i < dx; i++) {
        cout << 'R';
    }
    for (int i = 0; i < dy; i++) {
        cout << 'U';
    }
    for (int i = 0; i < dx; i++) {
        cout << 'L';
    }
    for (int i = 0; i < dy; i++) {
        cout << 'D';
    }

    cout << 'D';
    for (int i = 0; i < dx + 1; i++) {
        cout << 'R';
    }
    for (int i = 0; i < dy + 1; i++) {
        cout << 'U';
    }
    cout << 'L';
    cout << 'U';
    for (int i = 0; i < dx + 1; i++) {
        cout << 'L';
    }
    for (int i = 0; i < dy + 1; i++) {
        cout << 'D';
    }
    cout << 'R' << endl;
}   

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program
{
    static void Main()
    {
        var input = Console.ReadLine();
        var num = int.Parse(Regex.Replace(input, " ", ""));
        if (num >= 4 && num % 4 == 0)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 16184
let n = stdin.ReadLine() |> int
let s = stdin.ReadLine()

let f num x = if (num + x) > 90 then ((num + x) - 26) else (num + x)

let len = s.Length

let ls = [for i in 1..len do yield (s.[i - 1] |> int |> f n |> char |> string)]

let g (a:string) b = a + b

List.fold g "" ls
|> stdout.WriteLine

Measured memory_bytes: 35144
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static int[] B;
	static boolean[][] g;
	static boolean[] used;
	static HashMap<Long, Integer> memo;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			Country[] cs = new Country[N];
			used = new boolean[N];
			B = new int[N];
			for (int i = 0; i < N; ++i) {
				cs[i] = new Country();
				B[i] = cs[i].b;
			}
			used[0] = true;
			g = new boolean[N][N];
			for (int i = 0; i < N; ++i) {
				for (String o : cs[i].c) {
					for (int j = 0; j < N; ++j) {
						if (o.equals(cs[j].a)) {
							g[i][j] = true;
							if (i == 0) used[j] = true;
							break;
						}
					}
				}
			}
			int ans = B[0];
			for (int i = 0; i < N; ++i) {
				if (!used[i]) ans += solve(i);
			}
			System.out.println(ans);
		}
	}

	static int solve(int cur) {
		int pos = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();
		list.add(cur);
		used[cur] = true;
		while (pos < list.size()) {
			int c = list.get(pos++);
			for (int i = 0; i < N; ++i) {
				if (g[c][i] && !used[i]) {
					used[i] = true;
					list.add(i);
				}
			}
		}
		memo = new HashMap<Long, Integer>();
		return dfs(0, list, 0);
	}

	static int dfs(int pos, ArrayList<Integer> list, long st) {
		if (pos == list.size()) return 0;
		long ost = st;
		if (pos > 20 && memo.containsKey(((long) pos << 50) | ost)) {
			return memo.get(((long) pos << 50) | ost);
		}
		int cur = list.get(pos);

		// not use cur
		int ret = dfs(pos + 1, list, st | (1L << cur));

		// use cur
		if ((st & (1L << cur)) == 0) {
			st |= 1L << cur;
			int sum = B[cur];
			for (int i = pos + 1; i < list.size(); ++i) {
				if (g[cur][list.get(i)]) {
					st |= 1L << list.get(i);
				}
			}
			sum += dfs(pos + 1, list, st);
			ret = Math.max(ret, sum);
		}

		if (pos > 20) {
			memo.put(((long) pos << 50) | ost, ret);
		}
		return ret;
	}

	static class Country {
		String a;
		int b;
		String[] c;

		Country() {
			a = sc.next();
			b = sc.nextInt();
			int cc = sc.nextInt();
			c = new String[cc];
			for (int i = 0; i < cc; ++i) {
				c[i] = sc.next();
			}
		}
	}
}

Measured memory_bytes: 178304
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    int n;
    cin >> n;
    vector<int> t(n+1);
    vector<int> x(n+1);
    vector<int> y(n+1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    rep(i,n)    cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool ans = true;
    rep(i,n) {
        int time = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(t[i+1] - t[i] < time)    ans = false;
        if(((t[i+1] - t[i])%2) != (time%2))   ans = false;
    }

    if(ans) cout <<"Yes"<< endl;
    else    cout <<"No" <<endl;

 return 0;
}

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

int main(void) {
	int A, B;
	cin >> A >> B;

	int n = 0;
	while (true) {
		int s = A + (n - 1) * (A - 1);
		if (s >= B)
			break;
		++n;
	}

	cout << n << '\n';
	return 0;
}


Measured memory_bytes: 256