akhauriyash/Code-Regression huggingface dataset:
// abc161_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

vector<ll> get_divisors(ll n){
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++){
        if (i * i == n){
            res.emplace_back(i);
        }
        if (n % i == 0){
            res.emplace_back(i);
            res.emplace_back(n / i);
        }
    }
    sort(ALL(res));
    return res;
}

map<ll, int> factorize(ll n){
    ll tmp = n;
    map<ll, int> res;
    for (ll a = 2; a * a <= n; a++) { int cnt = 0; while (tmp % a == 0){ cnt++; tmp /= a; } if (cnt > 0) res[a] = cnt; }
    if (tmp > 1) res[tmp] = 1;
    return res;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N;
    cin >> N;
    // (aK+1) x K^b

    vector<ll> divisors = get_divisors(N);
    set<ll> st;
    for (auto div: divisors){
        if (div == 1) continue;

        ll k = div;
        ll k_b = 1;
        while (N % (k_b * k) == 0){
            k_b *= k;
            if ((N / k_b - 1) % k == 0){
                st.insert(k);
            }

            if (k_b >= (ll)numeric_limits<int>::max() &&
                k >= (ll)numeric_limits<int>::max()) break; // オーバーフローしちゃう
        }
    }

    vector<ll> divisors2 = get_divisors(N-1);
    for (auto div: divisors2){
        if (div == 1) continue;
        st.insert(div);
    }

//    print(divisors);
//    print(st);

    print(st.size());

//
//    int cnt = 0;
//    REPN(k, 1, N+1){
//        ll n = N;
//        while (n % k == 0 && k != 1) n /= k;
//        if (n % k == 1){
//            print(k);
//            cnt++;
//        }
//    }
//    print(cnt);


    return 0;
}


Measured memory_bytes: 384
# coding: utf-8


def main():
    _ = int(input())
    A = list(map(int, input().split()))
    B = [0] * 100002
    ans = 0

    for a in A:
        if a != 0: B[a - 1] += 1
        B[a] += 1
        B[a + 1] += 1

    ans = max(B)
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 20528
#include<iostream>
#include<set>
using namespace std;
int A,B;
void print(int a,int i)
{
	if(i==A+B)return;
	print(a/2,i+1);
	cout<<(char)('A'+!(a&1));
}
main()
{
	cin>>A>>B;
	set<int>s;
	for(int i=0;i<1<<A+B;i++)
	{
		int a=0,b=0;
		for(int j=A+B;j--;)
		{
			if(i&1<<j)a++;
			else b++;
			if(a<=3&&b==5||b<=3&&a==5)break;
		}
		if(a==A&&b==B)s.insert(-i);
	}
	for(int it:s)
	{
		print(-it,0);
		cout<<endl;
	}
}



Measured memory_bytes: 3100
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 2e5 + 2;

int n, a[N], b[N];
int c[N], d[N];                                                         // c, d contains index of a and b respectively

inline int Get(int mask, int k) { return mask & ((1 << k) - 1); }       // returns first k bit of mask

int Solve(int k, int lo, int hi)
{
    int ret = 0;
    for (int i = n - 1, l = 0, r = 0; i >= 0; --i)
    {
        while (l < n && Get(a[c[i]], k) + Get(b[d[l]], k) < lo) ++l;
        while (r < n && Get(a[c[i]], k) + Get(b[d[r]], k) < hi) ++r;
        ret ^= (r - l) & 1;
    }
    return ret;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]), c[i] = i;
    for (int i = 0; i < n; ++i) scanf("%d", &b[i]), d[i] = i;

    int res = 0;
    for (int k = 0; k < 29; ++k)
    {
        sort(c, c + n, [&](int x, int y) { return Get(a[x], k + 1) < Get(a[y], k + 1); });
        sort(d, d + n, [&](int x, int y) { return Get(b[x], k + 1) < Get(b[y], k + 1); });

        int T = 1 << k;
        if (Solve(k + 1, T, T * 2) ^ Solve(k + 1, T * 3, T * 4))
            res += T;
    }
    printf("%d", res);
    return 0;
}


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

using i64 = int64_t;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int sum = a + b + c + d;
    cout << sum / 60 << '\n' << sum % 60 << endl;

    return 0;
}



Measured memory_bytes: 3064
function main()
  
  (A,B,T) = map(x -> parse(Int,x), split(readline()))
  
  count = 0
  
  while true
    
    if A*count > T+0.5
      break
    end
    
    count += 1
    
  end
  
  println(B*(count-1))
  
end

main()

Measured memory_bytes: 109352
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int n, m, a, h, p, q;
int amida[105][1005];

int main() {
  while(1){
    cin>>n>>m>>a;
    if(m==0 && m==0 && a==0) break;
    REP(i,0,n)REP(j,0,1005) amida[i][j] = -1;
    REP(i,0,m){
      cin>>h>>p>>q;
      amida[p-1][h] = 1;
      amida[q-1][h] = 0; //:left
    }

    int ans = a-1;
    //REP(i,0,1005){
    for(int i = 1000; 0<=i; i--){
      if(amida[ans][i] == 0){
        ans--;
      }else if(amida[ans][i] == 1){
        ans++;
      }
    }
    cout<<ans+1<<endl;
  }
  return 0;
}

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

int v[200005];

int main() {
    int n;
    cin >> n;
    int cn = n -1;

    while (cn--) {
        int temp;
        cin >> temp;

        v[temp]++;
    }

    for (int i = 1; i <= n; ++i)
        cout << v[i] << " ";

    return 0;
}

Measured memory_bytes: 4400
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	P demand[m];
	rep(i, 0, m) {
		int a, b;
		cin >> a >> b;
		demand[i].first = b - 1;
		demand[i].second = a - 1;
	}
	sort(demand, demand + m);

	int ans = 0;
	int prev = -1;
	rep(i, 0, m) {
		if(demand[i].second < prev) continue;
		prev = demand[i].first;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(1e18 + 7)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	pair<ll, ll> ar[] = {{-1, 1}, {-1, -1}, {1, -1}, {1, 1}};	
	vector<ll> ve[4];
	ll n;
	cin >> n;
	for (ll i = 0; i < n ; i++) {
		ll x, y;
		cin >> x >> y;
		for (ll j = 0; j < 4; j++) {
			ve[j].push_back (x * ar[j].first + y * ar[j].second);
		}
	}
	ll ma = 0;
	for (ll i = 0; i < 4; i++) {
		sort (ve[i].begin (), ve[i].end ());
		ma = max (ma, *ve[i].rbegin () - *ve[i].begin ());
	}
	cout << ma << "\n";
}


Measured memory_bytes: 9696
import heapq
def heapify(x):
    for i in reversed(range(n//2)):
        _siftup(x, i)
 
n,m = map(int,input().split())
 
l = []
for i in range(n):
    ab = list(map(int,input().split()))
    l.append(ab)
l.sort()
q = []
ans = 0
cnt = 0
for i in range(1,m+1):
    while cnt < n and l[cnt][0] == i:
        heapq.heappush(q,-l[cnt][1])
        cnt += 1
    
    if len(q) != 0:
        ans += -heapq.heappop(q)
 
print(ans)

Measured memory_bytes: 73048
#include<stdio.h>

int main(void)

{

int a,b,c;

int count=0;

int i;

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

for(i=a;i<=b;i++)

{

if(c%i==0) count++;

}

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

return 0;

}
 

Measured memory_bytes: 2728
ans = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 8, 8, 11, 11, 11, 11, 14, 14, 32, 32, 35, 35, 35, 35, 42, 42, 42, 42, 49, 49, 49, 49, 49, 49, 75, 75, 86, 86, 86, 86, 86, 86, 123, 123, 131, 131, 131, 131, 148, 148, 153, 153, 170, 170, 170, 170, 170, 170, 227, 227, 227, 227, 227, 227, 250, 250, 323, 323, 324, 324, 324, 324, 354, 354, 354, 354, 384, 384, 384, 384, 384, 391, 491, 491, 529, 529, 529, 529, 529, 529, 543]
print(ans[int(input())])

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;



int main(){
	int N;
	int a[100],b[100],c[100],d[100];
	P red[100],blue[100];
	P red2[100],blue2[100];
	bool u1[100],u2[100];
	bool can[100][100];
	int num[100];

	memset(num,0,sizeof(num));


	scanf("%d", &N);
	for(int i=0;i<N;i++){
		scanf("%d %d", &a[i], &b[i]);
		red[i] = make_pair(a[i],b[i]);
		red2[i] = make_pair(b[i],a[i]);
		u1[i] = false;
		u2[i] = false;
	}
	for(int i=0;i<N;i++){
		scanf("%d %d", &c[i], &d[i]);
		blue[i] = make_pair(c[i],d[i]);
		blue2[i] = make_pair(d[i],c[i]);
	}

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			can[i][j] = false;
		}
	}

	int ans = 0;
	sort(red,red+N);
	sort(blue,blue+N);

	for(int i=0;i<N;i++){
		int x1 = red[i].first;
		int y1 = red[i].second;
		bool found = false;
		int j2;
		int dis = 200;
		for(int j=0;j<N;j++){
			if(x1<blue[j].first && y1<blue[j].second){
				can[i][j] = true;
				num[i]++;
			}
		}
	}

	for(int j=0;j<N;j++){
		int m_i;
		bool found = false;
		for(int i=0;i<N;i++){
			if(can[i][j]){
				if(!found){
					found = true;
					m_i = i;
				}else if(num[m_i]>num[i]){
					m_i = i;
				}

			}
		}
		if(found){
			ans++;
			for(int i=0;i<N;i++){
				if(can[i][j] && i!=m_i)	num[i]--;
			}
			for(int k=0;k<N;k++) can[m_i][k] = false;
		}
	}


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

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    ll  n;
    cin >> n;
    ll p[n];
    ll min=MOD;
    ll ans = 0;
    for(int i = 0; i < n;i++){
        cin >> p[i];
        if(p[i] <= min){
            ans++;
            min = p[i];
        }
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int total = 0;
        
        for(int i=a;i>0;i--)
        total=total+i;
        
        System.out.println(total);
	}
}

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

int main(){
    int n,m,l,r,L[100000],R[100000];
    int ans = 0;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> L[i] >> R[i];
    }
    l = L[0];
    r = R[0];

    for (int i = 1; i < m; i++){
        if ( L[i] > l){
            l = L[i];
        }

        if ( R[i] < r ) {
            r = R[i];
        }
    }

    for (int i = 1; i <= n; i++){
        if ( i >= l && i <= r ) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#!python3

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

# input
N, M = LI()
A, B = [None] * M, [None] * M
for i in range(M):
    A[i], B[i] = LI()
    A[i] -= 1
    B[i] -= 1

# link
link = [[] for _ in range(N)]
for a, b in zip(A, B):
    link[a].append(b)
    link[b].append(a)


def solve(w):
    l = link[0]
    visit = [False] * N
    visit[0] = True
    for x in l:
        visit[x] = True
        w[x] = 1
    while len(l) > 0:
        next_list = []
        for x in l:
            for v in link[x]:
                if not visit[v]:
                    visit[v] = True
                    w[v] = x + 1
                    next_list.append(v)
        l = next_list
    
    return True


def main():
    w = [None] * N
    solve(w)
    print("Yes")
    for ans in w[1:]:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40536
A, B = gets.split.map(&:to_i)
S = gets.chomp
if S.count("-")==1 && S[0..(A-1)].gsub(/[0-9]/, '').empty? && S[-B..-1].gsub(/[0-9]/, '').empty?
  puts 'Yes'
else
  puts 'No'
end


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

bool prime[1000001];
int dp[1000001];

void seive(int s){
	for(int i=0;i<=s;i++)prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<=s;i++){
		if(prime[i]){
			for(int j=i*2;j<=s;j+=i)prime[j]=false;
		}
	}
}

void pp(int s){
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=s;i++){
		dp[i]=dp[i-1]+prime[i];
	}
}

int main(void){
	seive(1000000);
	pp(1000000);
	int n;
	while(1){
		int ans=0;
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			int p,m;
			scanf("%d%d",&p,&m);
			int ff=max(p-m,0);
			int tt=min(p+m,1000000);
			ans+=dp[tt]-dp[ff]+prime[ff];
		}
		printf("%d\n",ans-n);
	}
    return 0;
}

Measured memory_bytes: 0
def merge(A, n ,left, mid, right):
    cnt = 0
    L = A[left:mid] + [float("inf")]
    R = A[mid:right] + [float("inf")]
    i, j = 0, 0
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return cnt

def mergeSort(A, n, left, right):
    if left+1 < right:
        mid = (left + right)//2
        return mergeSort(A, n, left, mid) + mergeSort(A, n, mid, right)\
        + merge(A, n, left, mid, right)    
    return 0

n = int(input())

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

cnt = mergeSort(A, n, 0, n)

print(*A)
print(cnt)


Measured memory_bytes: 63428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,m,i,j,ans=0;
  	cin>>n>>m;
  	vector<pair<ll,ll>> a(n);
 	for(i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
    }

  	sort(a.begin(),a.end());
  	
  	for(i=0;i<n;i++){
		if(a[i].second<m){
          m-=a[i].second;
          ans+=(a[i].first)*(a[i].second);
        }else{
		  ans+=m*(a[i].first);
          break;
        }
    }

  	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
 
using namespace std;
using lli = long long int;
 
int main(void){
    int a,b;
    cin >> a >> b;
    int total = (a+b)/2;
    if((a+b)%2==1 )total++;
    cout << total << endl;
}

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

void Solve()
{
    ll ans=0,n,m,sumpre=0,sumpost=0;
    cin>>n>>m;
    vector <ll> prefix(n+2),postfix(n+2);
    
    for(int i=0;i<=n;i++)
    {
        sumpre += i;
        sumpost += n-i;
        sumpre %= MOD;
        sumpost %= MOD;
        prefix.at(i) = sumpre;
        postfix.at(i) = sumpost;
    }

    for(int i=m-1;i<n;i++)
    {
        ans += postfix.at(i)-prefix.at(i)+1;
        ans %= MOD;
    }
    if(ans<0)
        ans += MOD;
    cout<<ans+1;

}

int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
        Solve();
    return 0;
}

Measured memory_bytes: 6428
#![allow(unused_mut)]

use std::io::{self, BufWriter, Write};
use std::error::Error;

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() -> Result<(), Box<dyn Error>> {
    let sout = io::stdout();
    let mut o = BufWriter::new(sout.lock());
  
    input! {
        // input
        l : i32,
        r : i32,
        d : i32,
    }

    // operate
    let mut c = 0;
    for i in l .. r + 1 {
        if i % d == 0 {
            c = c + 1;
        };
    }

    let line = format!("{}\n", c);
    o.write(line.as_bytes())?;
    Ok(())
  }


Measured memory_bytes: 2148
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var p = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var evenall = true;
        for (int i = 0; i < n; i++)
            if (a[i] % 2 == 1) { evenall = false; break; }
        if (evenall) Console.WriteLine(p == 0 ? Math.Pow(2, n) : 0);
        else Console.WriteLine(Math.Pow(2, n - 1));
    }
}

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

int main(void)
{
    int n,m,tot=0,c=0;
    cin >> n>> m;
    int a[n];
    for(int i=0;i<n;i++)
    {
      cin >> a[i];
      tot=tot+a[i];
    }
    double x=1/(4*(double)m);
    for(int i=0;i<n;i++)
    {

      double y= (double)a[i]/(double)tot;
      if(y<x)
      {
        c++;
      }
    }

    int l=n-c;
    if(l>=m)
    {
      cout << "Yes";
    }
    else
    {
      cout << "No";
    }

    return 0;

}


Measured memory_bytes: 256
//666yuchen
#include<bits/stdc++.h>
using namespace std;
int n,a;
vector<int>b;
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++)
  {
  	scanf("%d",&a);
  	if((i+n)%2)b.push_back(a);
  	else b.insert(b.begin(),a);
  }
  for(int i=0;i<n;i++)printf("%d ",b[i]);
  return 0;
}

Measured memory_bytes: 3060
n,m,l = [int(i) for i in input().split()]
a = [0 for i in range(n)]
b = [0 for i in range(m)]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    a[i] = [int(i) for i in input().split()]
for i in range(m):
    b[i] = [int(i) for i in input().split()]
for i in range(n):
    for j in range(l):
        c[i][j] = sum([a[i][k]*b[k][j] for k in range(m)])
for i in c:
    print(*i,sep=" ")


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

int main() {
	int W,H, x, y,r;
	bool overflag=false;
	std::cin >>W>>H>>x>>y>>r;
	if(x<r || x>W-r) overflag=true;
	if(y<r || y>H-r) overflag=true;
	if(overflag)
		std::cout << "No" <<std::endl;
	else
		std::cout << "Yes" <<std::endl;
	return 0;
}

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	int Z = S.size();
	stack<char>T;
	rep(i, Z) {
		if (S[i] == '0'||S[i]=='1') {
			T.push(S[i]);
		}
		else {
			if(!T.empty())
			T.pop();
		}
	}
	stack<char>TT;
	while (!T.empty()) {
		TT.push(T.top());
		T.pop();
	}
	while (!TT.empty()) {
		cout << TT.top();
		TT.pop();
	}
	cout << endl;
}

Measured memory_bytes: 256
n,l=map(int,input().split())
nl=[l+i-1 for i in range(1,n+1)]
mini=10**5
for i in nl:
    mini=min(mini,abs(i))
if mini in nl:
    nl.remove(mini)
if len(nl)==n:
    nl.remove(-mini)
print(sum(nl))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	int BS,OT,point;
	string s;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		BS = 0;
		OT = 0;
		point = 0;
		while(OT!=3)
		{
			cin >> s;
			if(s=="HIT")
			{
				BS++;
				if(BS>3)
				{
					point++;
					BS--;
				}
			}
			else if(s=="HOMERUN")
			{
				point+=(1+BS);
				BS=0;
			}
			else
			OT++;
		}
		printf("%d\n",point);
	}
}

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

const int64_t MOD= 1000000007;
const int Nfac= 2000007;
/* 剰余環 Z_n */
struct mint{ // Z_n に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }

  mint pow(int64_t d) const{ // d \geq 0
    if(d==0) return 1;
    else{
      mint ans= pow(d>>1);
      ans*= ans;
      if(d&1){ ans*= *this; }

      return ans;
    }
  }

  // MOD が素数(<=> Z_n が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};

/* 階乗,二項係数 */
vector<mint> fac(Nfac+1), ifac(Nfac+1);
void fact_modp_init(int N= Nfac){
  fac.at(0)= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    fac.at(i)= fac.at(i-1)* buf;
  }

  ifac.at(N)= fac.at(N).inv();
  for(int i=N; i>0; i--){
    buf= i;
    ifac.at(i-1)= ifac.at(i)* buf;
  }
}

mint choose_modp(int n, int k){
  if(n < 0 || min(n,n-k) < 0) return 0;
  else return fac.at(n)* ifac.at(k)* ifac.at(n-k);
}
// ^^^ テンプレここまで ^^^
mint route(int r, int c){
  return choose_modp(r+c, c);
}

int main() { // S= f(r_2 +1, c_2 +1)- f(r_2 +1, c_1)- f(r_1, c_2 +1)+ f(r_1, c_1)
  int r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;

  fact_modp_init(r2+c2+2);
  mint ans= route(r2+1, c2+1)- route(r2+1, c1)- route(r1, c2+1)+ route(r1, c1);

  cout << ans.rep << endl;
}

Measured memory_bytes: 31488
n, m = gets.chop.split.map(&:to_i)

if m != 0
  include_number = Hash.new(0)
  tmp_wa_hash = Hash.new(0)
  wa_hash = Hash.new(0)

  ac_count = 0
  wa_count = 0
  m.times {
    arr = gets.chop.split
    number = arr[0].to_i
    if arr[1] == 'AC' && include_number[number] == 0
      ac_count += 1
      include_number[number] = 1
      if wa_hash[number] == 0
        wa_hash[number] = tmp_wa_hash[number]
        wa_count += wa_hash[number]
      end
    elsif arr[1] == 'WA'
      tmp_wa_hash[number] += 1
    end
  }
  print ac_count.to_s + ' ' + wa_count.to_s
else
  print '0 0'
end

Measured memory_bytes: 14716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(void){
	int h,w;
	
	while(cin >> h >> w){
		if((h|w) == 0) break;
		
		char tmpc;
		string tmps;
		vector<string> senbei,working;
		for(int i=0;i<h;i++){
			tmps = "";
			for(int j=0;j<w;j++){
				cin >> tmpc;
				tmps += tmpc;
			}
			senbei.push_back(tmps);
		}
		
		int maxi = 0;
		//for all pattern of reversing rows
		for(int i=0;i<1<<h;i++){
			int tmpnum=0;
			working = senbei;
			//reverse determined row
			for(int j=0;j<h;j++){
				if(i&1<<j){
					for(int k=0;k<w;k++){
						if(working[j][k] == '0'){
							working[j][k] = '1';
						}else{
							working[j][k] = '0';
						}
					}
				}
			}
			//count for each column
			int maxincol;
			for(int j=0;j<w;j++){
				maxincol = 0;
				for(int k=0;k<h;k++){
					if(working[k][j] == '0'){
						maxincol++;
					}
				}
				tmpnum += max(maxincol, h - maxincol);
			}
			maxi = max(maxi, tmpnum);
		}
		cout << maxi << endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;
typedef long long int ll;

int n,a[100010],cs=0,r=0;
bool q=false,up,bad;

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        cs++;
        if(cs>1 and q==false){
            if(a[i]!=a[i-1]){
                q=true;
                up=a[i]>a[i-1];
            }
        }
        if(q){
            if(up){
                bad=a[i]<a[i-1];
            }
            else bad=a[i]>a[i-1];
            
            if(bad){
                //printf("%d\n",i);
                q=false;
                cs=1;
                r++;
            }
        }
    }
    r++;
    printf("%d\n",r);
}

Measured memory_bytes: 640
string=input()
n=[]
for letter in string:
    n.append(letter)
if ('N' in n and 'S' not in n) or ('S' in n and 'N' not in n) or ('E' in n and 'W' not in n)or ('W' in n and 'E' not in n):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9120
#include <stdio.h>
#include <string.h>
char s[100000];
int alphabet[26];
int len;
int check(int x){
  int i;
  for(i=0;i<26;i++){
    if(alphabet[i]>x/2)return 1;
  }
  return 0;
}

int main(){
  int i,j,k;
  scanf("%s",s);
  len=strlen(s);
  for(i=0;i<len-1;i++){
    if(s[i]==s[i+1]){
      printf("%d %d\n",i+1,i+2);
      return 0;
    }
  }
  for(i=1;i<len-1;i++){
    if(s[i-1]==s[i+1]){
      printf("%d %d\n",i,i+2);
      return 0;
    }
  }
  printf("-1 -1\n");
  return 0;
}


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

int main() {

    ll N;
    cin >> N;
    N--;
    ll ans = 0;
    for (int i = 2; ; i++) {
        ll qoi = N / i;
        if ( qoi <= i) break;
        if ( (qoi * i + (i-1)) == N)
            ans += qoi;
    }

    if (N != 1) ans += N;
    cout << ans << '\n';

    /* 
    for (int N = 1; N < 50; N++) {

    ll ans = N;
    for (int i = 2; ; i++) {
        ll qoi = N / i;
        if ( qoi < i) break;
        if ( (qoi * i + (i-1)) == N)
            ans += qoi;
    }

    cout << ans << '\n';
    }
    */



}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib> 
#include<cmath>
#include<iostream>
using namespace std;

bool isPrime(int n)
{
	for(int i=2;i<sqrt(n)+0.5;++i)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

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

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


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

  int q;
  cin >> q;
  vector<int> M(q);
  for(int i = 0;i < q;i++){
      cin >> M.at(i);
  }

  map<int,int> make;
  for (int bit = 0;bit < (1<<n); ++bit){
    int kari = 0;
    for(int i = 0;i < n;i++){
        if(bit & (1<<i)){
            kari+=A.at(i);
        }
      }
    make[kari] = 1;
    }
    
  for(int i = 0;i < q;i++){
      int m = M.at(i);
      if (make[m] == 1){
          cout << "yes" << endl;
      }else{
          cout << "no" << endl;
      }
  }

  
}


Measured memory_bytes: 3132
#include <cstdio>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define modp(x, y) (((y) + (x) % (y)) % (y))

struct st
{
	int a, b, c;
};

int N, L;
char S[2][53];

int M;
st domino[30];

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	scanf("%s", S[0]);
	scanf("%s", S[1]);
	L = strlen(S[0]);

	int bef = -1;
	ll ans;
	for(int i = 0; i < L; i++)
	{
		if(S[0][i] == S[1][i])
		{
			if(bef == 0)
			{
				ans *= 2;
			}
			else if(bef == -1)
			{
				ans = 3;
			}
			bef = 0;
		}
		else
		{
			if(bef == 0) 
			{
				ans *= 2;
			}
			else if(bef == -1)
			{
				ans = 6;
			}
			else
			{
				ans *= 3;
			}
			bef = 1;
			i++;
		}
		ans %= 1000000007;
	}
	printf("%lld\n", ans);

	return 0;
}


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

using namespace std;

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

int main(){
   
   int n,m;
   cin >> n >> m;
   char a[60][60], b[60][60];

   rep(i,n){
      rep(j,n){
         cin >> a[i][j];
      }
   }

   rep(i,m){
      rep(j,m){
         cin >> b[i][j];
      }
   }

   rep(i,n){
      rep(j,n){
         if(a[i][j] == b[0][0]){
            int flag = 1;
            rep(k,m){
               rep(l,m){
                  if(a[i + k][j + l] != b[k][l]) flag = 0;
               }
            }
            if(flag == 1){
               cout << "Yes" << endl;
               return 0;
            }
         }
      }
   }
   cout << "No" << endl;

   return 0;
}

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

int a[3100];
int main() {
	int N;cin >> N;
	for (int i = 0;i < N;i++)cin >> a[i];
	int fm=0;
	for (int j = 0;j < N;j++) {
		fm += a[j] - 1;
	}
	cout << fm << endl;
	return 0;
}

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

namespace ConsoleApp15
{
    class Class94
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            long[] A = new long[N];
            long[] B = new long[N];
            for (int i = 0; i < N; i++)
            {
                var r = Console.ReadLine().Split();
                A[i] = int.Parse(r[0]);
                B[i] = int.Parse(r[1]);
            }

            long count = 0;
            for (int i = N - 1; i >= 0; i--)
            {
                count += (B[i] - (A[i] + count) % B[i])%B[i];
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 18636
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    
    ll cnt=0;
    map<char,int> dic;
    rep(i,s.size()){
        char c=s[i];
        cnt+=i-dic[c];
        dic[c]++;
    }
    cout1(cnt+1)
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

ll dp[200000][13];
int main() {
  string s;
  cin >> s;
  int n = sz(s);
  
  dp[0][0] = 1;
  auto f = [&](int i, int x){
      for(int j=0;j<13;j++){
       int a = (j*10+x)%13;
       dp[i+1][a]+=dp[i][j];
       dp[i+1][a]%=mod;
     }
  };
  rep(i,n){
    if(s[i] == '?'){
      rep(k,10)f(i,k);
    }else{
     int x = s[i]-'0';
     f(i,x);
    }
  }
  cout<<dp[n][5]<<endl;
  return 0;
}

Measured memory_bytes: 13864
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    int minimum;
    minimum=min(n,k);
    int ans;
    ans=minimum*x;
    n-=minimum;
    ans+=n*y;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,x,y,z;
    cin>>a>>b>>c>>x>>y>>z;
    x=a+b;
    y=b+c;
    z=a+c;
    if(x==c){
        cout<<"Yes"<<endl;
    }else if (y==a){
        cout<<"Yes"<<endl;
    }else if (z==b){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin >> a >>b;
    
    cout << (a+b+1)/2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int N;
    cin>>N;
    int ans=1;
    bool a=true;
    while(a==true){
        if(N<ans*2){
            a=false;
        }
        else{
            ans*=2;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	long long int N,T,t[200000],ans=0;
	cin>>N>>T;
	for(int i=0;i<N;i++)
	{
		cin>>t[i];
		if(i>=1)
		{
			if(t[i]-t[i-1]>T)ans+=T;
			else ans+=t[i]-t[i-1];
		}
	}
	ans+=T;
	cout<<ans;
	return 0;
	}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
  int n,k;
  cin>>n>>k;
  vector<char> s(n+1);
  rep(i,1,n+1)cin>>s[i];
  s[k]=s[k]+0x20;
  rep(i,1,n+1)cout<<s[i];
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
	int cnt = 0;
	int n; long double d;
	 cin >> n >> d;
	for(int i{}; i<n; i++){
		long double x,y; cin >> x >> y;
		if(sqrt((x*x)+(y*y))<=d){
			cnt++;
		}
	}

	cout << cnt << "\n";
    
}





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

const int64_t MOD= 1000000007;
const int Nfac= 2000007;
#define MEMORY 0 // 1/0: 階乗を配列に格納をする前処理をする/しない
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }

  mint pow(int64_t d) const{ // d \geq 0
    if(d==0) return 1;
    else{
      mint ans= pow(d>>1);
      ans*= ans;
      if(d&1){ ans*= *this; }

      return ans;
    }
  }

  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};

/* 階乗,二項係数 */
#if (MEMORY==1)
// 前処理として,階乗を配列に格納をするver.
vector<mint> mfac(Nfac+1), ifac(Nfac+1);
void fact_modp_init(int N= Nfac){
  mfac.at(0)= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    mfac.at(i)= mfac.at(i-1)* buf;
  }

  ifac.at(N)= mfac.at(N).inv();
  for(int i=N; i>0; i--){
    buf= i;
    ifac.at(i-1)= ifac.at(i)* buf;
  }
}
#else
// 前処理を回避するver.
void fact_modp_init(int N= Nfac){}
mint mfac(int N){
  mint ans= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    ans*= buf;
  }

  return ans;
}
#endif
// ^^^ テンプレここまで ^^^
mint binom_modp(int n, int k){
  k= min(k, n-k);
  if(n < 0 || k < 0) return 0;
  
  mint ans= 1;
  for(int i=1; i<=k; i++){
    mint num= n-i+1;
    mint den= i;
    ans*= num*den.inv();
  }
  return ans;
}

int main() {
  string S,T;
  cin >> S >> T;

  cout << T+S << endl;
}

Measured memory_bytes: 256
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
import numpy as np
# import heapq
# from collections import deque

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

B = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

num_minus = len(B[B < 0])
abs_tot = sum(list(map(abs, A)))
if num_minus % 2 == 0:
    print(abs_tot)
else:
    n_0 = 10**9
    for i in A:
        a = abs(i)
        if a < n_0:
            n_0 = a
    print(abs_tot - (n_0 * 2))

Measured memory_bytes: 37808
#include <cstdio>
#include <iostream>

using namespace std;

int mount(int P, int n, int k, int N[]) {
	int cnt = 0;
	for (int i = 0; i < k; ++i) {
		int w = 0;
		while (w + N[cnt] <= P) {
			w += N[cnt++];
			if (cnt == n)
				return n;
		}
	}
	return cnt;
}

int main() {

	int n, k;
	scanf("%d %d", &n, &k);

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

	int left = 0;
	int right = 1000000000;
	while (left < right) {
		int mid = (left + right) / 2;
		if (mount(mid, n, k, N) == n) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	cout << right << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll from;
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n, q;
vl a, b, p, x;
vl cost;
vll G;
/******* define variable end *******/
vector<bool> seen;
void dfs(ll v){
	seen[v] = true;
	for(auto nv : G[v]){
		if(seen[nv]) continue;
		cost[nv] += cost[v];
		dfs(nv);
	}
}
int solve() {
	cin >> n >> q;
	RES(a, n-1);
	RES(seen, n);
	RES(G, n);
	RES(b, n-1);
	RES(cost, n);
	RES(p, q);
	RES(x, q);
	REP(i, n-1){
		cin >> a[i] >> b[i];
		G[a[i]-1].push_back(b[i]-1);
		G[b[i]-1].push_back(a[i]-1);
	}
	REP(i, q){
		cin >> p[i] >> x[i];
		cost[p[i]-1] += x[i];
	}
	dfs(0);
	REP(i, n){
		cout << cost[i] << " ";
	}
	cout << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

int main()
{
	long long int n,j=0;
	cin>>n;
	
	vector<string>v,d;
	vector<int>a,c;
	map <string ,int>m;
	for(long long int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(m.find(s)==m.end())
		{
			m.insert({s,1});
			j++;
		}
		else{
			m[s]++;
		}
	}
	 map<string, int> :: iterator it2;
	for(it2=m.begin(); it2!=m.end(); it2++)
	{
		v.push_back(it2->first);
		a.push_back(it2->second);
	}
		
	
	c=a;
	sort(a.begin(),a.end());
	
	for(long long int i=0;i<c.size();i++)
	{
		if(a[a.size()-1]==c[i])
		{
			d.push_back(v[i]);
		}
	}
	sort(d.begin(),d.end());
	for(long long int i=0;i<d.size();i++)
	{
		cout<<d[i]<<endl;
	}
	return 0;
}

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

int main()
{
    int n,w;
    std::cin>>n>>w;
    std::vector<std::pair<int,int>> p(n);
    for(int i=0;i<n;i++)std::cin>>p[i].first>>p[i].second;
    std::vector<std::vector<long long>> dp(n, std::vector<long long>(100100,100000000000000000)); //dp[i][j] : i番目まで見た時,価値j以上にできる最小の重さ
    dp[0][p[0].second] = p[0].first;
    for(int i=0;i<n;i++)dp[i][0] = 0;
    for(int i=1;i<n;i++){
        for(int j=0;j<=100000;j++){
            //使う場合
            if(j-p[i].second>=0)dp[i][j] = std::min(dp[i][j],dp[i-1][j-p[i].second] + p[i].first);
            dp[i][j] = std::min(dp[i-1][j],dp[i][j]);
        }
    }
    long long res = 0;
    
    for(int i=100000;i>=0;i--){
        if(dp[n-1][i]<=w&&dp[n-1][i]!=10000000000000000){res = i;break;}
    }
    std::cout<<res<<std::endl;
    /*
    for(int i=30;i!=-1;i--){
        std::cout<<i<<" ";
        for(int j=0;j<n;j++){
            //if(dp[j][i]==10000000000000000)dp[j][i] = 0; 
            std::cout<<dp[j][i]<<" ";
        }
        std::cout<<std::endl;
    }
    */

}

Measured memory_bytes: 79488