akhauriyash/Code-Regression huggingface dataset:
N = gets.chomp
K = gets.to_i
L = N.size

dpA = Array.new(L + 1) { Array.new([K + 1, L + 1].max, 0) }
dpB = Array.new(L + 1) { Array.new([K + 1, L + 1].max, 0) }

N.chars.map(&:to_i).each_with_index do |n, i|
  0.upto(n) do |v|
    next if i == 0 && v == 0

    if v == n
      0.upto(i) do |nonzero_count|
        if v == 0
          dpA[i + 1][nonzero_count] += dpA[i][nonzero_count]
        else
          if i == 0
            dpA[i + 1][nonzero_count + 1] += 1
          else
            dpA[i + 1][nonzero_count + 1] += dpA[i][nonzero_count]
          end
        end
      end
    else
      0.upto(i) do |nonzero_count|
        if v == 0
          dpB[i + 1][nonzero_count] += dpA[i][nonzero_count]
        else
          if i == 0
            dpB[i + 1][nonzero_count + 1] += 1
          else
            dpB[i + 1][nonzero_count + 1] += dpA[i][nonzero_count]
          end
        end
      end
    end
  end

  if i > 0
    0.upto(9) do |v|
      if v != 0
        dpB[i + 1][1] += 1
      end

      1.upto(i) do |nonzero_count|
        if v == 0
          dpB[i + 1][nonzero_count] += dpB[i][nonzero_count]
        else
          dpB[i + 1][nonzero_count + 1] += dpB[i][nonzero_count]
        end
      end
    end
  end
end

puts dpA[L][K] + dpB[L][K]


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, n);
  int ans = 0;

  for (int i = 1; i <= n; i += 2) {
    int divisor = 0;
    for (int j = 1; j <= i; ++j) divisor += (i % j == 0);
    ans += (divisor == 8);
  }

  cout << ans << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.chomp.to!int - 1).array;
    auto B = new int[](N);
    foreach (i; 0..N) B[A[i]] = i;

    int ans = 1;
    int tmp = 1;
    foreach (i; 0..N-1) {
        if (B[i] < B[i+1])
            tmp++;
        else
            tmp = 1;
        ans = max(ans, tmp);
    }

    ans = N - ans;
    ans.writeln;
}


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

int main() {
  string s;
  int x, y;
  cin >> s >> x >> y;
  s += 'T';
  bool flg_x = false, fst = true;
  int d = 0;
  vector<int> dx, dy;
  for (char c : s) {
    if (c == 'F') {
      d++;
    } else if (fst) {
      x -= d;
      fst = false;
      d = 0;
    } else {
      if (flg_x) {
        dx.push_back(d);
      } else {
        dy.push_back(d);
      }
      flg_x = !flg_x;
      d = 0;
    }
  }
  x = abs(x);
  y = abs(y);
  if (x > s.size()) {
    cout << "No" << endl;
    return 0;
  }
  vector<vector<bool>> dp_x(dx.size() + 1, vector<bool>(2 * s.size() + 1));
  dp_x.at(0).at(s.size()) = true;
  for (int i = 0; i < dx.size(); i++) {
    for (int j = 0; j <= 2 * s.size(); j++) {
      if (j >= dx.at(i)) dp_x.at(i + 1).at(j) = dp_x.at(i + 1).at(j) || dp_x.at(i).at(j - dx.at(i));
      if (j <= 2 * s.size() - dx.at(i)) dp_x.at(i + 1).at(j) = dp_x.at(i + 1).at(j) || dp_x.at(i).at(j + dx.at(i));
    }
  }
  if (!dp_x.at(dx.size()).at(s.size() + x)) {
    cout << "No" << endl;
    return 0;
  }
  vector<vector<bool>> dp_y(dy.size() + 1, vector<bool>(2 * s.size() + 1));
  dp_y.at(0).at(s.size()) = true;
  for (int i = 0; i < dy.size(); i++) {
    for (int j = 0; j <= 2 * s.size(); j++) {
      if (j >= dy.at(i)) dp_y.at(i + 1).at(j) = dp_y.at(i + 1).at(j) || dp_y.at(i).at(j - dy.at(i));
      if (j <= 2 * s.size() - dy.at(i)) dp_y.at(i + 1).at(j) = dp_y.at(i + 1).at(j) || dp_y.at(i).at(j + dy.at(i));
    }
  }
  if (!dp_y.at(dy.size()).at(s.size() + y)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 15360
#include <iostream> 
#include <cstdio>
#define mod 1000000007
#define maxn 100010
#define LL long long

int n,k;

int prime[maxn],not_prime[maxn],phi[maxn],tot;
LL ans;

LL quick_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;
}

void linear_shaker(int x)
{
	phi[1]=1;
	
	for(int i=2;i<=x;++i)
	{
		if(!not_prime[i])
		    prime[++tot]=i,phi[i]=i-1;
		
		for(int j=1;i*prime[j]<=x;j++)
		{
			if(i%prime[j]==0)
			    phi[i*prime[j]]=phi[i]*prime[j];
			else 
			    phi[i*prime[j]]=phi[i]*phi[prime[j]];
			    
			not_prime[i*prime[j]]=1;
			
			if(i%prime[j]==0) break;
		}
	}
}

int main()
{
	scanf("%d%d",&n,&k);
	linear_shaker(k);
	
	for(int i=1;i<=k;++i)
		ans=(ans+quick_pow(k/i,n)*phi[i]%mod)%mod;
		
	printf("%lld\n",ans);
	
	return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> c(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> c[i][j];
  rep(i, h) rep(j, 2) {
    rep(k, w) cout << c[i][k];
    cout << endl;
  }
  return 0;
}

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

#define debug(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair

int n,m,a[30],x,n4,n2,n1,i;
char c;

bool cmp(int x,int y){
	return x>y;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for (i=0;i<n;i++){
		for (int j=0;j<m;j++){
			cin>>c;
			a[c-'a']++;
		}
	}
	sort(a,a+26,cmp);
	for (i=0;i<26;i++){
		if (a[i]) x++;
	}
	if (n%2 && m%2){
		n1=1;
	}
	if (n%2){
		n2+=m/2;
	}
	if (m%2){
		n2+=n/2;
	}
	n4=(n*m-2*n2-n1)/4;
	i=0;
	while (a[i]){
		while (a[i]>=4 && n4){
			n4--;
			a[i]-=4;
		}
		while (a[i]>=2 && n2){
			n2--;
			a[i]-=2;
		}
		if (a[i] && n1){
			n1--;
			a[i]--;
		}
		if (a[i]){
			cout<<"No";
			return 0;
		}
		i++;
	}
	cout<<"Yes";
	return 0;
}

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

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

   int x, y;
   cin >> x >> y;

   if((y - (2 * x)) % 2 == 0 and y >= 2* x and (4*x - y) % 2==0 and 4 * x >= y)
       cout << "Yes\n";
   else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3540
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int x=stdIn.nextInt(),y=stdIn.nextInt(),d;
		if(y>x){
			d=x;
			x=y;
			y=d;
		}
		while(y>0){
			d=x%y;
			x=y;
			y=d;
		}
		System.out.println(x);
	}
}


Measured memory_bytes: 26264
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;
int main(){


ll a,b,c,d;

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

ll ans = max(a * c, max(a * d, max(b * c, b * d)));

cout << ans << endl;

return 0;

}


Measured memory_bytes: 3628
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

void solve() {
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(n,b-1);
    cout<<x*a/b-a*(x/b);
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	int x;
	cin>>x;
	cout<<x+x*x+x*x*x<<endl;
	return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main()
{
    int a,b,c,m;
    scanf("%d %d %d",&a,&b,&c);
    m=a*b;
    if(c>m)
    {
        printf("%d",m);
    }
    else
    {
        printf("%d\n",c);
    }
    return 0;
 
}

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

int main() {
  int N, check;
  cin >> N;
  check = 0;
  
  for(int i = 0;i < 30;i++){
    for(int j = 0;j < 20;j++){
      if(4 * i + 7 * j == N)
        check = 1;
    }
  }
  
  if(check == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s,s3;

	int ara[n_size],ara2[n_size];

	cin>>s>>s3;

	if(s>s3) cout<<">"<<endl;
	else if(s<s3) cout<<"<"<<endl;
	else cout<<"="<<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//define
#define fast ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define file  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long
#define ld  double
# define PI 3.14159265358979323846
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define in(x) (int)(x-'0')
using namespace std;
int main(){
    fast
    vector<int>pp,nn;
    ll n,k;
    cin>>n>>k;
    vector<ll>v;
    ll arr[n];
    ll j = 0;
    for (int i = 0; i < n; ++i) {
        cin>>arr[i];
    }
    ll mn = 1e18;
    for(int i = 0;i<n;i++){
        ll j = i+k-1;
        if(j>=n)continue;
        if(arr[i] <0 && arr[j]<=0 ){
            mn = min(mn,abs(arr[i]));
        }else if(arr[i] < 0 && arr[j] >0){
            mn = min(mn , 2*min(abs(arr[i]),abs(arr[j]))+max(abs(arr[i]),abs(arr[j])) );
        }else{
            mn= min(mn,arr[j]);
        }
    }
    cout<<mn<<endl;
    return 0;
}

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

using namespace std;
vector<int> six = {6,36,216,1296,7776,46656};
vector<int> nine = {9,81,729,6561,59049};


int main(){
    vector<int> min_val(100000);
    for(int i = 0; i < 6; i++)
        min_val[i] = i;
    for(int i = 6; i < 9; i++)
        min_val[i] = i - 6 + 1;
    int n;
    cin >> n;
    for(int i = 9; i <= n; i++){
        int six_min = 1, nine_min = 1;
        for(vector<int>::iterator it = six.begin(); it < six.end(); it++){
            if(i < *it) break;
            six_min = *it;
        }
        
        for(vector<int>::iterator it = nine.begin(); it < nine.end(); it++){
            if(i < *it) break;
            nine_min = *it;
        }
        min_val[i] = min(min_val[i - six_min], min_val[i - nine_min]) + 1;
    }
    cout << min_val[n] << endl;
    return 0;
}


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


    #define s scanf
    #define p printf
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define tmax(a, b, c) max(max(a, b), c)

    using namespace std;

    const int INF = 1e9;
    const long long LINF = 1e18+5;
    const double eps = 0.0000001;
    fstream fin, fout;
    typedef pair<int, int> ii;
    typedef vector<ii> vii;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<bool> vb;
    typedef vector<char> vc;
    typedef vector<vector<int> > vvi;
    typedef vector<ll> vll;

    int main(){
    string a; cin >> a;
    if(a.size() == 2) cout << a;
    else{
        reverse(all(a));
        cout << a;
    }
    }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	long long int N,K;
	cin >> N >> K;
	long long int sum=K;
	for(int i=0;i<N-1;i++){
		sum = sum *(K-1);
	}
	cout << sum << endl;
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	
	vector<double> dp(N + 1); // dp[N] = probability of having N heads
	dp[0] = 1; // before having flipped any coins, the probability of having 0 heads is 1
	for (int i = 0; i < N; ++i)
	{
		double p;
		cin >> p;
		for (int j = i + 1; j >= 0; --j)
		{
			dp[j] = dp[j]*(1-p) + (j == 0 ? 0 : dp[j-1]*p);
		}
	}
	
	double answer = 0;
	for (int i = N/2 + 1; i <= N; ++i)
		answer += dp[i];
	cout << setprecision(10) << answer << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Console;

namespace CPLib
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int h = s[0];
            int w = s[1];
            int k = s[2];
            char[,] map = new char[h, w];
            //red → Rとする
            for (int i = 0; i < h; i++)
            {
                string input = ReadLine();
                for (int j = 0; j < w; j++)
                {
                    map[i, j] = input[j];
                }
            }
            //実装部
            //行と列を選んで(2^6 * 2^6)シュミレーション
            char[,] tmpmap = new char[h, w];
            int ans = 0;
            for (int hbit = 0; hbit < (1 << h); hbit++)
            {
                for (int wbit = 0; wbit < (1 << w); wbit++)
                {
                    Array.Copy(map, tmpmap, map.Length);
                    //edit_tmpmap
                    for (int i = 0; i < h; i++)
                    {
                        if (((hbit>>i)&1) == 1)
                        {
                            //i行目が選ばれた
                            for (int j = 0; j < w; j++)
                            {
                                tmpmap[i, j] = 'R';
                            }
                        }
                    }
                    for (int i = 0; i < w; i++)
                    {
                        if (((wbit >> i) & 1) == 1)
                        {
                            //i列目が選ばれた
                            for (int l = 0; l < h; l++)
                            {
                                tmpmap[l, i] = 'R';
                            }
                        }
                    }

                    //count
                    int cnt = 0;
                    foreach (var item in tmpmap)
                    {
                        if (item == '#') cnt++;
                    }
                    if (cnt == k) ans++;
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int x;
	cin>>x;
	x=x%7;
	switch(x){
		case 1:
			cout<<"fri"<<endl;
			break;
		case 2:
			cout<<"sat"<<endl;
			break;
		case 3:
			cout<<"sun"<<endl;
			break;
		case 4:
			cout<<"mon"<<endl;
			break;
		case 5:
			cout<<"tue"<<endl;
			break;
		case 6:
			cout<<"wed"<<endl;
			break;
		case 0:
			cout<<"thu"<<endl;
			break;
	}
	return 0;
}


Measured memory_bytes: 3112
# coding: utf-8
# Your code here!
import collections

N=int(input())
A=list(map(int,input().split()))

l=[0]
for i in range(N):
    temp=l[-1]+A[i]
    l.append(temp)

c=collections.Counter(l)
#print(l)
#print(c)

_, count=zip(*c.most_common())

ans=0
for item in count:
    ans+=item*(item-1)//2
    
print(ans)
#for item in l:
    


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

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	int sum = 0;
	int col[110] = {0};
	for(int i = 0; i < n; i++) {
		int row = 0;
		for(int j = 0; j < m; j++) {
			int a;
			scanf("%d", &a);
			row += a;
			col[j] += a;
			printf("%d ", a);
			if(j == m-1) printf("%d", row);
		}
		sum += row;
		printf("\n");
	}
	for(int i = 0; i < m; i++)
		printf("%d ", col[i]);
	printf("%d\n", sum);
}



Measured memory_bytes: 3212
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():

    N = input()

    for i, row in enumerate(N):
        if row.isupper() == True:
            N = N[:i] + row.lower() + N[i+1:]
        elif row.islower() == True:
            N = N[:i] + row.upper() + N[i+1:]

    print(N)

if __name__ == '__main__':
    main()




Measured memory_bytes: 5704
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

int main() {

    ll N,M,R; cin >> N >> M >> R;
    vector<ll> r(R);
    REP(i,R) cin >> r[i];

    REP(i,R) r[i]--;
    sort(r.begin(), r.end());

    ll dist[300][300];
    REP(i,300)REP(j,300) dist[i][j] = 1e18;
    REP(i,N) dist[i][i] = 0;

    REP(i,M) {
        ll A,B,C;
        cin >> A >> B >> C;
        A--, B--;
        dist[A][B] = C;
        dist[B][A] = C;
    }
    
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans = 1e18;
    do {
        ll d = 0;
        REP(i,r.size() - 1) d += dist[r[i]][r[i+1]];
        ans = min(ans, d);
    } while(next_permutation(r.begin(), r.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	A := readInt64()
	B := readInt64()
	C := readInt64()
	D := readInt64()

	g := gcd64(C, D)
	e := C / g * D

	ca := (A - 1) / C
	da := (A - 1) / D
	ea := (A - 1) / e

	cb := B / C
	db := B / D
	eb := B / e

	println((B - (cb + db - eb)) - (A - 1 - (ca + da - ea)))
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int maxn = 11;

int n = 0;
int a[maxn];

typedef long long ll;

ll ans = 0;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", a+i);
    for (int i = 0; i < (1<<n); i++) {
        int t = 1, o = 0;
        for (int j = 0; j < n; j++) {
            if ((i>>j)&1) {
                if (a[j] & 1) {
                    t *= 2;
                }
                o = 1;
            } else if (!(a[j] & 1)) t *= 2;
        }
        if (o) {
            ans += t;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  rep(i,60000){
    if(i*108/100==n){
      print(i);
      return 0;
    }
    else if(i==59999){
      print(":(");
    }
  }
}

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

int main()
{
    string N;
    cin >> N;
    bool isYes = true;

    for(int i=0; i<N.size()/2; i++)
    {
        if(N[i]!=N[N.size()-i-1]) isYes = false; 
    }

    if(isYes) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	cout << (A*B) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

unordered_set<string> s;

lli n;

int main(){
    string st;
    string con;
    cin >> n;
    for(lli i = 0;i < n;i++){
        cin >> st >> con;
        if(st == "insert") s.insert(con);
        if(st == "find") cout << (s.count(con) ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 32088
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	ans = k;
	for (int i = 0; i < n - 1; i++)
		ans *= k - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  string s;cin >> s;
  map<pair<string,string>,int> mp;
  rep(n,1<<N){
    string t,u;
    rep(i,N){
      if((n>>i)&1) t.push_back(s[i]);
      else u.push_back(s[i]);
    }
    ++mp[make_pair(t,u)];
  }

  reverse(all(s));
  ll ans = 0;
  rep(n,1<<N){
    string t,u;
    rep(i,N){
      if((n>>i)&1) t.push_back(s[i]);
      else u.push_back(s[i]);
    }
    if(mp.count(make_pair(t,u))) ans += mp[make_pair(t,u)];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	string s,t;
	cin>>s>>t;
	deque<char> q;
	for(int i=0;i<s.length();++i){
		q.push_back(s[i]);
	}

	if(s.length()!=t.length()){
		puts("No");
		return 0;
	}	

	string temp=s;
	if(s.compare(t)==0){
		puts("Yes");
		return 0;
	}

	bool ok=1;
	while(1){

		char c=q.bk;
		q.push_front(c);
		q.pop_back();
		ok=1;
		string ans;
		for(auto x:q){
			ans+=x;
		}
		// cout<<ans<<'\n';

		if(ans.compare(t)==0){
			ok=1;
			break;
		}

		if(ans.compare(temp)==0){
			ok=0;
			break;
		}

	}

	if(!ok){
		puts("No");
	}
	else{
		puts("Yes");
	}
	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3556
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9+7;
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  string s;
  cin>>s;
  rep(i,0,s.size())
    cout<<'x';
  cout<<endl;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> pre[N];
    for(int i = 0; i < M; i++) {
        int P, Y;
        cin >> P >> Y;
        P--;
        pre[P].emplace_back(Y, i);
    }
    ll ans[M];
    for(ll i = 0; i < N; i++) {
        sort(pre[i].begin(), pre[i].end());
        for(int j = 0; j < pre[i].size(); j++) {
            ans[pre[i][j].second] = (i + 1) * 1000000 + (j + 1);
        }
    }
    for(int i = 0; i < M; i++) {
        printf("%012lld\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 7808
import heapq
x, y, z,  k = map(int, input().split())
a = list(int(x) for x in input().split())
b = list(int(x) for x in input().split())
c = list(int(x) for x in input().split())

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab_1 = []
for i in a:
    for j in b:
        heapq.heappush(ab_1, -i-j)
key1 = min([k, x*y])
ab_2 = []
for i in range(key1):
    value = heapq.heappop(ab_1)
    ab_2.append(-value)

abc = []
for p in ab_2:
    for q in c:
        heapq.heappush(abc, -p-q)
key2 = min([k, x*y*z])
for i in range(key2):
    value = heapq.heappop(abc)
    print(-value)

Measured memory_bytes: 194072
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;
int a[200010],b[200010];
int s[200010],t[200010];
signed main(){
  int n,m,k;cin>>n>>m>>k;
  rep(i,n+1){
    if(i!=n)cin>>a[i];
    if(i==0)s[i]=0;
    else s[i]=s[i-1]+a[i-1];
  }
  rep(i,m+1){
    if(i!=m)cin>>b[i];
    if(i==0)t[i]=0;
    else t[i]=t[i-1]+b[i-1];
  }
  int ans=0;
  rep(i,n+1){
    int sum=k-s[i];
    if(sum<0)continue;
    int po=lower_bound(t,t+m+1,sum+1)-t;
    po--;
    ans=max(ans,i+po);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9756
// AOJ 2508 "王様の視察" (ICPC模擬国内予選 2013 Problem A)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            int[] k = new int[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.nextInt();
            }
            StringBuffer s = new StringBuffer(sc.next());
            
            for (int i = 0; i < s.length(); i++) {
                char tmp = s.charAt(i);
                int pos = station.indexOf(tmp);
                char newStation = station.charAt((pos + (52 - k[i%k.length])) % 52);
                s.setCharAt(i, newStation);
            }
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 24908
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<ll> p(n);
  rep(i,n) cin>>p[i];
  ll ch[100005] = {0};
  rep(i,n) if(p[i] == i+1) ch[i]++;
  ll ans = 0;
  rep(i,n){
    if(ch[i]>0){
      ans++;
      if(i!= n-1)ch[i+1] = 0;
    }
  }
  cout<<ans<<endl;

}

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


Measured memory_bytes: 1792
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {


    int a,b;

    cin >> a >> b ;
    
    int d, r;
    double f;
    
    d = a/b;
    r = a - b*d;
    f = 1.0*a/b;
    
    cout << d << " " << r << " ";// << f << endl;
    printf("%.8lf\n", f);
    
    
    return 0;
    
}



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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for (int i=0; i < N; i++) {
    cin >> card.at(i);
  }
  vector<int> count(N + 1, 0);
  for (int i=0; i < N; i++) {
    count.at(card.at(i))++;
  }
  vector<int> deg(N + 1, 0);
  for (int i=1; i <= N; i++) {
    deg.at(count.at(i))++;
  }
  vector<int> kdsum(N + 1, 0), dsum(N + 1, 0);
  for (int i=1; i <= N; i++) {
    kdsum.at(i) = kdsum.at(i - 1) + i * deg.at(i);
    dsum.at(i) = dsum.at(i - 1) + deg.at(i);
  }
  vector<int> fx(N + 1, 0);
  for (int i=1; i <= N; i++) {
      fx.at(i) = kdsum.at(i) / i + (dsum.at(N) - dsum.at(i));
  }
  sort(fx.begin(), fx.end());
  for (int k=1; k <= N; k++) {
    cout << N + 1 - ( lower_bound(fx.begin(), fx.end(), k) - fx.begin() ) << endl;
  }
}

Measured memory_bytes: 9472
import java.util.*;
import java.io.*;
class Main{
  public static void main(String[]args) {
      Scanner sc=new Scanner(System.in);
      int data[]=new int[3];
      for(int i=0;i<3;i++){
        data[i]=sc.nextInt();
      }
      for(int i=0;i<data.length;i++){
        for(int j=i+1;j<data.length;j++)
          if(data[i]>data[j]){
            int x=data[i];
            data[i]=data[j];
            data[j]=x;
          }
      }
      System.out.println(data[0]+" "+data[1]+" "+data[2]);
  }
}


Measured memory_bytes: 26120
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

const double EPS = 1e-10;
int N;
ll A[int(2e5 + 5)], B[int(2e5 + 5)];
pair <double, int> P[int(2e5 + 5)];

ll GCD(ll a, ll b){
	if (a < b) swap(a, b);
	if (b == 0) return 1;
	while (a % b != 0){
		a %= b; swap(a, b);
	}
	return b;
}

ll Pow(ll a, ll n){
	if (n == 0) return 1;
	else if (n % 2 == 0) return Pow(a * a % MOD, n / 2);
	else return a * Pow(a * a % MOD, n / 2) % MOD; 
}

map <Pll, int> cnt;
map <Pll, bool> visited;

int main(){
	scanf("%d", &N);
	for (int i = 0; i < N; i++){
		scanf("%lld%lld", A + i, B + i);
		ll G = GCD(abs(A[i]), abs(B[i]));
		A[i] /= G; B[i] /= G;
		cnt[mp(A[i], B[i])]++;
	}

	vector <Pll> Count;
	ll ZeroA = 0, ZeroB = 0, Zero = cnt[mp(0, 0)];
	visited[mp(0, 0)] = true;
	for (int i = 0; i < N; i++){
		Pll P = mp(A[i], B[i]);
		if (visited[P]) continue;
		visited[P] = true;
		if (P.fi == 0){
			ZeroA += cnt[P]; continue;
		}
		if (P.se == 0){
			ZeroB += cnt[P]; continue;
		}

		Pll P1 = mp(-1 * A[i], -1 * B[i]);
		Pll next1 = mp(B[i], -1 * A[i]);
		Pll next2 = mp(-1 * B[i], A[i]);

		Count.push_back(mp(cnt[P] + cnt[P1], cnt[next1] + cnt[next2]));
		visited[next1] = true;
		visited[P1] = true;
		visited[next2] = true;
	}
	Count.push_back(mp(ZeroA, ZeroB));

	ll ans = 1;
	for (int i = 0; i < Count.size(); i++){
		ll now = Pow(2, Count[i].fi) + Pow(2, Count[i].se) - 1;
		now %= MOD;
		ans *= now; ans %= MOD;
	}
	ans += Zero - 1; ans %= MOD;
	if (ans < 0) ans += MOD;
	printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 109544
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<int>

using namespace std;
using ll = long long;
using veci = vec(int);
using vecll = vec(ll);

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string S;
    cin >> S;

    // 1 first
    int cc = 0;
    rep(i, 0, S.size()-1)  {
        char c = '0';
        if (i%2==0) c = '1';
        if (S[i] != c) cc++;
    }


    // 0 first
    int cc1 = 0;
    rep(i, 0, S.size()-1)  {
        char c = '1';
        if (i%2==0) c = '0';
        if (S[i] != c) cc1++;
    }

    cout << min(cc, cc1) << endl;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  int x[n], y[n], b[n], p[n];
  rep (i, n) cin >> x[i] >> y[i] >> b[i] >> p[i];
  rep (i, n) {
    int res = x[i] * b[i] + y[i] * p[i];
    rep (j, 10) rep (k, 10) if (j >= 5 && k >= 2) res = min(res, max(0, b[i] - j) * x[i] + max(0, p[i] - k) * y[i] + (x[i] * j + y[i] * k) * 4 / 5);
    cout << res << endl;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long
#define f first
#define s second
using namespace std;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s1;
    cin >> s1;
    for( int i = 0; i < s1.size(); i++)
    {
        cout << 'x';
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }


  int sumA = 0;
  int sumB = 0;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for (int i = 0; i < n; i++){
    if (i % 2 == 0){
      sumA += a.at(i);
    } else {
      sumB += a.at(i);
    }
  }

  cout << sumA - sumB<< endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int h, w, a, b ;
  cin >> h >> w >> a >> b ;
  vector<vector<int>> grid(h,vector<int>(w,0)) ;
  
  REP(i,b){
    REP(j,a){
      grid.at(i).at(j) = 1 ;
    }
  }
  FOR(i,b,h){
    FOR(j,a,w){
      grid.at(i).at(j) = 1 ;
    }
  }
  
  REP(i,h){
    REP(j,w){
      cout << grid.at(i).at(j) ;
    }
    cout << endl ;
  }


  return 0 ;
}




Measured memory_bytes: 5120
def main():
    n = int(input())
    A = list(map(int,input().split()))
    q = int(input())
    for _ in range(q):
        a,b,c = map(int,input().split())
        res = 0
        for i in range(a,b):
            if A[i]==c:res+=1
        print (res)


if __name__ == '__main__':
    main()




Measured memory_bytes: 5640
#include<iostream>
#include<stdlib.h>
#include<string.h>

using namespace std;

void rotateVertical(int *dice ,char dirV)//S N
{
     //1 2 6 5 前  0 1 5 4
     //1 5 6 2 後  0 4 5 1
     int tempF[4] = {dice[0] ,dice[1] ,dice[5] ,dice[4]};
     int tempB[4] = {dice[0] ,dice[4] ,dice[5] ,dice[1]};
     int* temp = tempF;
     if(dirV == 'S')
     {
             dice[0] = temp[3];
             dice[1] = temp[0];
             dice[5] = temp[1];
             dice[4] = temp[2];       
     }
     else
     {
             temp = tempB;
             dice[0] = temp[3];
             dice[4] = temp[0];
             dice[5] = temp[1];
             dice[1] = temp[2]; 
     }     
}
void rotateHorizontal(int *dice ,char dirH)//W E
{
     //1 3 6 4 右 0 2 5 3 
     //1 4 6 3 左 0 3 5 2 
     int tempR[4] = {dice[0] ,dice[2] ,dice[5] ,dice[3]};
     int tempL[4] = {dice[0] ,dice[3] ,dice[5] ,dice[2]};
     int* temp = tempR;
     if(dirH == 'E')
     {
             dice[0] = temp[3];
             dice[2] = temp[0];
             dice[5] = temp[1];
             dice[3] = temp[2];         
     }
     else
     {
             temp = tempL;
             dice[0] = temp[3];
             dice[3] = temp[0];
             dice[5] = temp[1];
             dice[2] = temp[2];
     }    
}
int main(void)
{
    int i = 0 ,dice[6];
    string command;
    
    i = 0;
    while(i < 6)
    {
        cin >> dice[i++];
    }
    cin >> command;
    
    for(i = 0 ; i < command.length() ; i++)
    {
          if(command[i] == 'S' || command[i] == 'N')
          {
              rotateVertical(dice ,command[i]);      
          }
          else
          {
              rotateHorizontal(dice ,command[i]); 
          }
    }
    cout << dice[0] << endl;
    //system("pause");
}





Measured memory_bytes: 3212