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

using namespace std;

int main()
{
  string stt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int n;
  while(cin >> n, n){
    int k[101];
    for(int i = 0; i < n; i++) cin >> k[i];
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
      int idx = stt.find(s[i]);
      cout << stt[(idx + stt.size() - k[i%n]) % stt.size()];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
while true
  h,w = gets.split.map(&:to_i)
  break if h == 0 && w == 0

  h.times do |i|
    case i + 1
    when proc(&:odd?)
      ans = "#."*w
      puts ans[0...w]
    when proc(&:even?)
      ans = ".#"*w
      puts ans[0...w]
    end
  end
  print "\n"
end

Measured memory_bytes: 8880
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

LL t[505];
LL n,m;
vector<LL> v1;

LL check(LL p){
	v1.clear();
	int i,j,k;
	LL a,b,c;
	b=0;
	for(i=0;i<n;i++){
		a=t[i]%p;
		b+=a;
		v1.push_back(a);
	}
	sort(v1.rbegin(),v1.rend());
	c=b;
	b/=p;
	for(i=0;i<b;i++){
		c+=p-2*v1[i];
	}
	return c/2;
}

int main(){
	LL i,j,k;
	LL a,b,c;
	cin>>n>>m;
	a=0,b=0,c=0;
	for(i=0;i<n;i++){
		cin>>t[i];
		a+=t[i];
		if(b<t[i])b=t[i];
	}
	b+=m;
	for(i=1;i<=1e7;i++){
		if(i>b)break;
		if(a%i!=0)continue;
		if(check(a/i)<=m){
			c=a/i;break;
		}
		if(check(i)<=m)c=i;
	}
	cout<<c<<endl;
}
		
	


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


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

    int n;
    cin >> n;
    vector<ll> a(n), b(n), d(n);
    ll dif = 0,ans=0;
    rep(i, n){
        cin >> a[i];
        d[i] = a[i];
        dif += a[i];
    }
    rep(i, n){
        cin >> b[i];
        dif -= b[i];
        d[i] -= b[i];
    }
    if(dif<0){
        cout << -1 << endl;
        return 0;
    }
    rep(i,n)if(d[i]<0)
        d[i]=1e10;

    sort(d.begin(), d.end());

    rep(i,n){
        if(dif-d[i]<0)
            break;
        dif -= d[i];
        ans++;
    }
    cout << n-ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;


int main(){
  int N,K;
  cin >>N>>K;
  double win=0;
  for(int i=1;i<=N;i++){
    if(i>=K){win=win+(double)1;continue;}
    int g=i;
    double count=(double)1;
    while(true){
      count*=(double)2;g*=2;if(g>=K){break;}
    }
    win=win+((double)1/count);
  }
  cout<<setprecision(14)<<win/(double)N;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
 
  int k,x;
  scanf("%d %d", &k, &x);
	int min = x-k+1;
	int max = x+k-1;
	for (int i = min; i < max; i++) {
		printf("%d ", i);
	}
	printf("%d\n", max);
 
  return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        aa: [usize; n],
    }
    let mut aa = aa;
    aa.reverse();

    let mut range = (2, 2);
    for i in 0..n {
        let a = aa[i];
        let l = range.0;
        let r = range.1;
        if r/a*a < l {
            return println!("{}", -1);
        }
        let nl = l/a*a + if l%a==0 { 0 } else { a };
        let nr = r/a*a + (a-1);
        range = (nl, nr);
        // debug!(range)
    }
    println!("{} {}", range.0, range.1);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    string S, T;
    cin >> S >> T;
 
    //答えansを仮置きする。
    //これが十分に大きくないと不正解となるので、
    //この値なら絶対に正しい答えが出る、という値を仮置きすること
    int ans = T.size();
 
    //Sの何文字目から調べるかを全探索する
    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define replb(i, a, b) for (ll i = a; i >= b; i--)
#define repl(i, a, b) for (ll i = a; i < b; i++)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
#define pb push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
#define BRAHAMASTRA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull unsigned long long int

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	BRAHAMASTRA

	int n;
	cin>>n;
	string s;
	cin>>s;
	int count=0;
	int low=0,high=n-1;
	while(low<=high)
	{
		if(s[low]=='W' && s[high]=='R')
		{
			swap(s[low],s[high]);
			low++;
			high--;
			count++;
		}
		if(s[low]=='R')
			low++;
		if(s[high]=='W')
			high--;
	}
	cout<<count<<"\n";
}

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

const int INF = (int)1.01e9;

int cnt[24];

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n;
    while (cin >> n) {
        vector<int> d(n);
        for (int i = 0; i < n; i++) {
            cin >> d[i];
        }

        if (n > 23) {
            cout << 0 << endl;
            continue;
        }
        int ans = 0;
        for (int mask = 0; mask < (1 << n); mask++) {
            memset(cnt, 0, sizeof(cnt));
            for (int i = 0; i < n; i++) {
                if (mask & (1 << i)) {
                    if (cnt[d[i]]++ > 0) break;
                } else {
                    if (cnt[(24 - d[i]) % 24]++ > 0) break;
                }
            }
            cnt[0]++;
            int mn = INF;
            int last = -INF;
            for (int i = 0; i < 2 * 24; i++) {
                if (cnt[i % 24]) {
                    if (cnt[i % 24] > 1) mn = 0;
                    mn = min(mn, i - last);
                    last = i;
                }
                if (mn == 0) break;
            }
            ans = max(ans, mn);
            if (ans == 24 / (n + 1)) break;
        }
        cout << ans << endl;
    }


#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for a in range(N + 1):
    for b in range(N - a + 1):
        c = N - a - b
        if (0 <= c <= 2000) and (10000 * a + 5000 * b + 1000 * c == Y):
            print(a,b,c)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
N=int(input())
A=list(map(int, input().split()))

x=len(set(A))
if x==1:
  if A==[0]*N:
    print('Yes')
  else:
    print('No')
elif x==2:
  B=list(set(A))
  a,b=max(B),min(B)
  if b==0 and A.count(0)==(N//3):
    print('Yes')
  else:
    print('No')
elif x==3:
  B=list(set(A))
  a=max(B)
  c=min(B)
  b=sum(B)-a-c
  if A.count(a)==A.count(b) and A.count(b)==A.count(c):
    if a^b==c:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

  

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

int main(){
  vector<int> a = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  int k; cin>>k;
  cout<<a[k-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,m;
  cin>>n>>m;
  vector<int>h(n),d(n),a(m),b(m);
  rep(i,n) {
    cin>>h[i];
    d[i]++;
  }
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    if(h[a[i]]<h[b[i]])
      d[a[i]]=0;
    else if(h[a[i]]>h[b[i]])
      d[b[i]]=0;
    else{
      d[a[i]]=0;d[b[i]]=0;
    }
  }
  int ans=0;
  rep(i,n){
    if(d[i])
      ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b >= c){cout << "Yes" << endl;}
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int n;
		scanf("%d",&n);
		char s[n];
		int hai[26][2]={0,0};
		int flag[26]={0};
		scanf("%s",s);
		int i;
		for(i=0;i<n;i++){
				if(flag[s[i]-'a']==0){
						hai[s[i]-'a'][0]=i;
						flag[s[i]-'a']=1;
				}
				hai[s[i]-'a'][1]=i;
		}
		int max=0,tmp=0,j;
		for(i=0;i<n-1;i++){
				tmp=0;
				for(j=0;j<26;j++){
						if(flag[j]!=0){
								if(i>=hai[j][0]&&i<hai[j][1])tmp++;
						}
				}
				if(tmp>max){
						max=tmp;
				}
		}
		printf("%d\n",max);
		return 0;
}



Measured memory_bytes: 128
# ABC069 C - PushPush
from collections import deque
N = int(input())
A = list(map(int,input().split()))

B1 = deque()
B2 = deque()

for i in range(N):
    if i == 0:
        B1.appendleft(A[0])
        B2.appendleft(A[0])
    
    if i > 0 and i%2 == 1:
        B1.append(A[i])
        B2.appendleft(A[i])
    elif i > 0 and i%2 == 0:
        B1.appendleft(A[i])
        B2.append(A[i])

if N%2 == 1:
    B1 = list(B1)
    print(*B1)
elif N%2 == 0:
    B2 = list(B2)
    print(*B2)

Measured memory_bytes: 26044
#include<bits/stdc++.h>
using namespace std;
double ans;
int a[200005];
int n,k,x,ans1,tmp;
int main(){
   cin>>n>>k;
   for(int i=1;i<=n;i++)cin>>a[i];
   for(int i=1;i<=k;i++)tmp+=a[i];//先算出最左边窗口的值
   ans1=tmp;
   for(int i=k+1;i<=n;i++) {//    
    	tmp+=a[i]-a[i-k];
      ans1=max(ans1,tmp);
    }  
    ans=(k+ans1)/2.0; //ans为double，
printf("%.12lf",ans);
	return 0;
}

Measured memory_bytes: 1024
MOD=10**9+7

def moddiv(a,m):
    return pow(a,m-2,m)

def solve():
    res=-10**30
    minus,plus,zero=[],[],[]
    for i in range(N):
        if A[i]<0:
            minus.append(A[i])
        elif A[i]>0:
            plus.append(A[i])
        else:
            zero.append(A[i])
    cump=1
    plus.sort()
    minus.sort()
    for i in range(len(plus)):
        cump=cump*plus[i]%MOD
    j=0
    i=0
    cumm=1
    while(j<=min(len(minus),K)):
        if j>0:
            cumm=cumm*minus[j-1]*minus[j-2]%MOD
            newm=minus[j-1]*minus[j-2]
        else:
            newm=0
        isbig=True
        if K-j>len(plus):
            j+=2
            continue
        oldp=1
        while(K-j<len(plus)-i):
            cump=cump*moddiv(plus[i],MOD)%MOD
            if isbig:
                oldp*=plus[i]
            if oldp>newm:
                isbig=False
            i+=1
        if j>0:
            if newm>oldp:
                res=cumm*cump%MOD
        else:
            res=max(res,cumm*cump%MOD)
        j+=2
    if res!=-10**30:
        return res
    if len(zero)>0:
        return 0
    li=minus+plus
    li.sort(key=lambda x:abs(x))
    res=1
    for i in range(K):
        res=res*li[i]%MOD
    return res
N,K=map(int,input().split())
A=list(map(int,input().split()))

if min(A)>=0:
    res=1
    A.sort(reverse=True)
    for i in range(K):
        res=res*A[i]%MOD
elif max(A)<=0:
    res=1
    if not K%2:
        A.sort()
        for i in range(K):
            res=res*A[i]%MOD
    else:
        A.sort(reverse=True)
        for i in range(K):
            res=res*A[i]%MOD
else:
    res=solve()
print(res)

Measured memory_bytes: 107420
use List::Util qw(max min sum);

my ($n) = split(/\s+/, <>);
chomp(my @a = <STDIN>);

my $index=0;
my $max = $a[0];
for (0..$n-1) {
    if ($max<$a[$_]) {
	$max=$a[$_]; $index=$_;
    }
}
splice @a, $index, 1;

for (0..$n-1) {
    if ($_ == $index) {
	print max(@a), "\n";
    } else {
	print $max, "\n";
    }
}

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

int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=0;i*108/100<=N;++i){
    if(i*108/100==N){
      ans=i;
      break;
    }
  }

  if(ans==0){cout<<":("<<endl;}
  else{cout<<ans<<endl;}
}


Measured memory_bytes: 256
from collections import deque
import sys
def solve():
    input=sys.stdin.readline
    n,q=map(int, input().split())

    G=[[] for i in range(n)]
    #up_G=[0]*n#up_G[i]=頂点iの親
    for _ in range(n-1):
        a,b=map(int,input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)

    ans=[0]*n
    for _ in range(q):
        p,x=map(int,input().split())
        ans[p-1]+=x
    #(G,v,p)=(グラフ(木の情報),探索中の頂点,vの親)
    #vの子の頂点を決めて、vをpに移す
    q=deque()
    q.append((0,-1))
    while q:
        V,P=q.popleft()
        for new_v in G[V]:
            #new_vが頂点の時はアウト
            if new_v==P:continue
            ans[new_v]+=ans[V]
            q.append((new_v,V))
    print(*ans)
solve()

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    ll num=1;
    for(int i=0; i<m; i++) num*=2;
    cout << num*(m*1900+(n-m)*100) << endl;
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll r;

    cin >> r;

    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main{
	public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        if(n.equals("Sunny")){
            System.out.println("Cloudy");
        }
        if(n.equals("Cloudy")){
            System.out.println("Rainy");
        }
        if(n.equals("Rainy")){
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
    int N, a[100001], i, b[100001];
    scanf("%d", &N);
    for (i = 1; i <= N; i++)
    {
        scanf("%d", &a[i]);
    }
    for (i = 1; i <= N; i++)
    {
        b[a[i]] = i;
    }
    for (i = 1; i <= N; i++)
    {
        printf("%d", b[i]);
        if (i != N)
        {
            printf(" ");
        }
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  int l[n]; rep(i,n) cin>>l[i];
  sort(l,l+n);
  int ans=0;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      int key=lower_bound(l+j+1,l+n,l[i]+l[j])-l;
      //cout<<l[i]<<" "<<l[j]<<" "<<l[key]<<endl;
      ans+=(key-j-1);
    }
  }
  //rep(i,n) cout<<l[i]<<" ";
  //cout<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 3612
from collections import Counter
N = int(input())

C = Counter(input())  # 最初の文字を入力

for _ in range(N - 1):
    Ctmp = Counter(input())
    for k, v in C.items():
        if k in Ctmp:
            C[k] = min(C[k], Ctmp[k])
        else:
            C[k] = 0


ans = []
for k, v in C.items():
    ans.extend([k]*v)
ans.sort()

print("".join(ans))


Measured memory_bytes: 3316
N = int(input())
h = list(map(int,input().split()))
ans = True
for i in range(N-2,-1,-1):
    if h[i] > h[i+1]:
        h[i]-=1
for i in range(N-1):
    if h[i] <= h[i+1]:
        ans = True
    else:
        ans = False
        break
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int H,W;
    cin >> H >> W;
    
    vector<vector<char>> a(H,vector<char>(W));
    
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            cin >> a.at(i).at(j);
        }
    }
    
    vector<bool> line(H,true);
    vector<bool> row(W,true);
    
    
    int L_counter=0;
    int R_counter=0;
    
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if(a.at(i).at(j) != '.'){
                line.at(i) = false;
                break;
            }
        }
        if(line.at(i)){
            L_counter++;
        }
    }
    
    for (int j=0; j<W; j++) {
        for (int i=0; i<H; i++) {
            if(a.at(i).at(j) != '.'){
                row.at(j) = false;
                break;
            }
        }
        if(row.at(j)){
            R_counter++;
        }
    }
    
    /*
    cout <<endl;
    
    int x = H - L_counter;
    int y = W - R_counter;
    vector<vector<int>> G(x, vector<int>(y));
    vector<int> op(x*y);
    int c=0;
    */
    
    for (int i=0; i<H; i++) {
        if(line.at(i)){
            continue;;
        }
        for (int j=0; j<W; j++) {
            if(row.at(j)){
                continue;
            }
            else{
                cout << a.at(i).at(j);
            }
        }
        cout <<endl;
    }
}


Measured memory_bytes: 3592
import Control.Monad
import Data.List

main=do
    n<-readLn
    putStrLn.f ['a'..'z'] =<< replicateM n (sort <$> getLine)

f [] = const []
f (a:ar) = liftM2 (++) (flip replicate a.minimum.map length.fst) (f ar.snd).unzip.map (span(==a))

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    for (int x = (25*n + 27 - 1)/27 ; x < (25*(n+1) + 27 - 1)/27 ; ++x) {
        cout << x << endl;
        return 0;
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF = 1000000000;
int n, s, sum, sma = INF;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        sum += s;
        if (s % 10) sma = min(sma, s);
    }
    if (sum % 10) cout << sum << endl;
    else if (sma == INF) cout << 0 << endl;
    else cout << sum - sma << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
// End Template IO/Utility
void solve(){
	int n;
	string s;
	cin>>n>>s;
	if((int)s.size()<=n)
		cout<<s;
	else cout<<s.substr(0,n)+"...";
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3644
#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>;

const int INF = 1001001001;

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));
  int max = 0;
  rep(i,N){
    cin >> C.at(i);
    if(max < C.at(i)){
      max = C.at(i);
    }
    rep(j,M){
      int tmp;
      cin >> tmp;
      A.at(i).at(j) = tmp;
    }
  }

  int ans = INF;
  for(int bit = 0;bit < (1<<N);++bit){
    int sum = 0;
    vector<int> tmp(M);
    for(int i=0;i<N;i++){
      if(bit & (1<<i)){
        sum += C.at(i);
        rep(j,M){
          tmp.at(j) += A.at(i).at(j);
        }
      }
    }
    bool ok = true;
    rep(i,M) if(tmp.at(i) < X) ok = false;
    if(ok) ans = min(ans,sum);
  }
  if(ans==INF){
    cout << "-1" <<endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();

    int ans = 0;
    rep(i, n) {
        if (s[i]!=t[i]) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
 
int main(){
    double r;
    cin>>r;
    double ans=2*r*acos(-1);
 
    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3784
#include<stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  int h[n], count=0, max=0, j=0, max_j=-1;
  
  for(int i=0; i<n; i++) scanf("%d", &h[i]);
  for(int i=0; i<n-1; i++)
  {
    if(max_j >= i) continue;
    for(j=i; j<n-1; j++)
    {
      if(h[j] >= h[j+1]) count++;
      else break;
    }
    max_j = j;
    if(max < count) max = count;
    count = 0;
  }
  
  printf("%d", max);
  
  return 0;
  
}

Measured memory_bytes: 512
import collections
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*M
C = [0]*M
table = collections.defaultdict(int)
for x in A:
    table[x] += 1
for i in range(M):
    B[i], C[i] = map(int, input().split())
    table[C[i]] += B[i]

count = N
ans = 0
table = list(table.items())
table.sort(key=lambda x: x[0], reverse=True)
for x in table:
    if count > x[1]:
        count -= x[1]
        ans += x[0]*x[1]
    else:
        ans += x[0]*count
        break

print(ans)


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

int main(){
  string s, ans;
  cin >> s;
  int y = (s[0]-48)*1000 + (s[1]-48)*100 + (s[2]-48)*10 + (s[3]-48);
  int m = (s[5]-48)*10 + (s[6]-48);
  int d = (s[8]-48)*10 + (s[9]-48);
  
  if(y == 2019 && m < 5) ans = "Heisei";
  else if(y < 2019) ans = "Heisei";
  else ans = "TBD";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a == b && b == c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3572
/* vo00_08.cpp */
#include <iostream>
using namespace std;

int main()
{
	int n, count;

	while (true) {
		cin >> n;
		if (cin.eof()) { break; }

		count = 0;
		for (int a = 0; a <= 9; ++a)
			for (int b = 0; b <= 9; ++b)
				for (int c = 0; c <= 9; ++c)
					for (int d = 0; d <= 9; ++d)
						if (n == a + b + c + d) { count++; }

		cout << count << '\n';

	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;

namespace AtcoderSubmit
{
    class Program
    {
        static void Main(string[] args)
        {
            const ulong MAX = 1000000000000000000uL;

            ulong result = 1;
            _ = Console.ReadLine();
            var x = Console.ReadLine().Split(' ').Select(a => ulong.Parse(a)).ToArray();
            if(x.Contains(0uL)) {
                Console.WriteLine(0);
                return;
            }
            foreach(var item in x) {
                double a = (double)MAX / result;
                if((double)MAX / result < item) {
                    Console.WriteLine(-1);
                    return;
                }
                result *= item;
                if(result > MAX) {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 41700
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

bool endwith(const string &s, const string &p)
{
  for (int i = 0; i < LEN(p); ++i) {
    if (s[LEN(s)-i-1] != p[LEN(p)-i-1]) return false;
  }
  return true;
}

signed main()
{
  int N;
  string s, t;
  cin >> N >> s >> t;

  s = s.substr(0, N);
  t = t.substr(LEN(t)-N, N);

  int ans = LEN(s) + LEN(t);
  for (int i = 1; i <= LEN(t); ++i) {
    const string &tmp = t.substr(0, i);
    if (endwith(s, tmp)) {
      ans = LEN(s) + LEN(t) - LEN(tmp);
    }
  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
import fractions
n,m = map(int,input().split())
lis = list(map(int,input().split()))
num = lis[0]
for i in range(1,n):
  num = fractions.gcd(num,lis[i])
if m <= max(lis) and m % num == 0:
  print("POSSIBLE")
else:print("IMPOSSIBLE")

Measured memory_bytes: 16240
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 2000005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   string s;
   cin>>s;
   int val=(s[0]-'0')*100;
   val+=(s[2]-'0')*10;
   val+=(s[3]-'0')*1;
   n*=val;
   cout<<(n/100)<<endl;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int asd(long long a,long long b)
{
	if(a==0) return b;
	else asd(b%a,a);
}
int n;
long long a[100005],ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	int ans=a[0];
	for(int i=1;i<n;i++) ans=asd(ans,a[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#15:34
n = int(input())
a = list(map(int,input().split()))
a.sort()
b = [0 for _ in range(10**6+1)]
ans = 0
for i in range(n):
  if b[a[i]]:
    continue
  now = int(a[i])
  ans += 1
  while True:
    try:
      b[now] = 1
      now += a[i]
    except:
      break
  if i != n-1:
    if a[i+1] == a[i]:
      ans -= 1
print(ans)

Measured memory_bytes: 164164
import sys
S = str(input())
K = int(input())

if len(S) == 1:
    print(S[0])
    sys.exit()

count = 0
l = 0
for i in range(len(S)):
    if S[i] == '1':
        count += 1
    else:
        break
#print(count)
    
if count < K:
    print(S[count])
else:
    print(1)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  rep(y, k + 1) rep(z, k + 1) {
    if(y + z > k) continue;
    if(a >= b * pow(2, y) || b * pow(2, y) >= c * pow(2, z)) continue;
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 4068
#include<cstdio>
#include<algorithm>
#include<queue>

#define INF 1<<29

class state{
	public:
	int p,v;
	state(){}
	state(int a,int b){
		p=a;v=b;
	}
	bool operator < (const state &a) const{
		return v > a.v;
	}
};
using namespace std;

int main(){
	while(1){
		int n,m;
		scanf("%d%d",&m,&n);
		if(n==0 && m==0){
			break;
		}
		int cost[101][101];
		int time[101][101];
		
		for(int i=0;i<101;i++)
		for(int j=0;j<101;j++)
		cost[i][j]=time[i][j]=INF;
		
		for(int i=0;i<m;i++){
			int a,b,c,d;
			scanf("%d%d%d%d",&a,&b,&c,&d);
			cost[a][b]=cost[b][a]=c;
			time[a][b]=time[b][a]=d;
		}
		
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			int st,en,va;
			scanf("%d%d%d",&st,&en,&va);
			
			priority_queue<state> aa;
			
			int meen[101];
			int visit[101]={0};
			
			for(int i=0;i<101;i++){meen[i]=INF;}
			
			aa.push(state(st,0));
			meen[st]=0;
			int ans=0;
			while(1){
				state u = aa.top();
				aa.pop();
				
				if(u.p==en){
					ans=u.v;
					break;
				}
				
				visit[u.p]=1;
				
				for(int i=1;i<=n;i++){
					if(visit[i]==0){
						int val=cost[i][u.p];
						if(va==1){
							val=time[i][u.p];
						}
						if(val+u.v < meen[i]){
							meen[i]=val+u.v;
							aa.push(state(i,meen[i]));
						}
					}
				}
			}
			printf("%d\n",ans);
		}
	}
}

Measured memory_bytes: 908
#include <stdio.h>

int main(void)
{
	int a,i,j;
	
	for(i = 1;i <= 9;i++){
		for(j = 1;j <= 9;j++){
			a = i * j;
			printf("%dx%d=%d\n",i,j,a);
		}
	}
	return 0;
}

Measured memory_bytes: 524
n,x=map(int,input().split())
lis=list(map(int,input().split()))
ans=[0]
for i in range(n):
    ans.append(ans[i]+lis[i])
#print(ans)
for i in range(n+1):
    if ans[n-i]<=x:
        a=n-i+1
        break

print(a)


Measured memory_bytes: 2940
#!/usr/bin/env python3


def solve(n, a):

    c = [ai // (n + 1) for ai in a]
    r = sum(c)
    b = [a[i] + r - (n + 1) * c[i] for i in range(n)]
    ans = r

    min_b = min(b)
    if n < min_b:
        r = min_b - n
        b = [bi - r for bi in b]
        ans += r * n

    while True:
        max_b = -1
        j = -1
        for i in range(n):
            if max_b < b[i]:
                max_b = b[i]
                j = i
        if max_b < n:
            break
        ans += 1
        b[j] -= n + 1
        for i in range(n):
            b[i] += 1

    return ans


def main():
    n = input()
    n = int(n)
    a = list(map(int, input().split()))

    print(solve(n, a))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s,ans;
    cin >> s;
    int i;
    for(i=0; i<s.length(); i++){
        if(i==0){
            ans="x";
        }else{
            ans+="x";
        }
    }
    cout << ans << endl;
    return 0;
}

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


struct Node {int parent, lc, rs;};
struct Node T[mx];
int D[mx];


int sldepth(int u,int p){
  D[u]=p;
  if(T[u].rs!=NIL)sldepth(T[u].rs,p);
  if(T[u].lc!=NIL)sldepth(T[u].lc,p+1);
}

int kind(int num){
  if(T[num].parent==NIL)return 0;//root
  else if(T[num].lc==NIL)return 1;//leaf
  else return 5;//internal
}

void children(int num){
  if(T[num].lc==NIL)cout<<"[]"<<endl;
  else{
    cout<<"["<<T[num].lc;
    int k=T[num].lc;
    while(T[k].rs!=NIL){
      cout<<", "<<T[k].rs;
      k=T[k].rs;
    }
    cout<<"]"<<endl;
  }
}

void display(int num){
  cout<<"node "<<num<<": parent = "<<T[num].parent<<", depth = "<<D[num];
  if(kind(num)==0)cout<<", root, ";
  else if(kind(num)==1)cout<<", leaf, ";
  else cout<<", internal node, ";
  children(num);
}

int main(){
  int n;
  cin>>n;
  rep(i,n)T[i].parent=NIL;
  int chilnum;
  int node;
  rep(i,n){
    cin>>node>>chilnum;
    vector<int>a(chilnum);
    rep(j,chilnum){
      cin>>a[j];
      T[a[j]].parent=node;
    }
    if(chilnum>0)T[node].lc=a[0];
    else T[node].lc=NIL;
    if(chilnum>1){
      rep(j,chilnum-1){
        T[a[j]].rs=a[j+1];
      }
      T[a[chilnum-1]].rs=NIL;
    }else if(chilnum==1)T[a[0]].rs=NIL;

  }
  int r;
  rep(i,n){
    if(T[i].parent==NIL){
      T[i].rs=NIL;
      r=i;
      break;
    }
  }

  sldepth(r,0);
  
  rep(i,n)display(i);


  //rep(i,n)cout<<i<<":"<<T[i].rs<<endl;
  return 0;
}


Measured memory_bytes: 7740
#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);
    
    ll N,K;
    cin>>N>>K;
    
    ll ans=0;
    if(K%2==0){
        ll n=N/K;
        ans+=n*n*n;
        if(N-(K/2)>=0){
            n=(N-K/2)/K+1;
            ans+=n*n*n;
        }
    }else{
        ll n=N/K;
        ans+=n*n*n;
    }
    cout1(ans)
}

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


int main(){


    int n,x;
    cin>>n;

    map<int,int>mp;
    long long int s=0;

    for(int i=0;i<n;i++)
    {
        cin>>x;
        mp[x]++;
        s+=x;
    }


    int q;
    cin>>q;

    while(q--){
        int b,c;
        cin>>b>>c;

        if(mp[b]==0)
        {
            cout<<s<<endl;
            continue;
        }

        else{
           long long int z=mp[b];
           mp[b]=0;
           s=s-(z*b);
           mp[c]+=z;
           s=s+(z*c);

           cout<<s<<endl;



        }
    }




    return 0;
}


Measured memory_bytes: 7740
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	while(cin>>n){
    	int sum=0;
      	for(int i=1;i<=n;i++){
        	for(int j=1;j<=n;j++){
            	for(int k=1;k<=n;k++){
                	sum+=__gcd(i,__gcd(j,k));
                }
            }
        }
        cout<<sum<<endl;
    }
  return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999

using namespace std;

typedef long long ll;

int main()
{
	int n;
	
	while (cin >> n) {
		int count = 0;
		for (int i = 0; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				for (int k = 0; k <= 9; k++) {
					if (n - 9 <= i + k + j&&i + k + j <= n)count++;
				}
			}
		}
		cout << count << endl;
	}

	return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    LL N;
    cin >> N;
    vector<LL> A(N), B(N);

    map<LL, LL> sa, sb;

    REP(i, N) {
        LL x;
        cin >> x;
        A[i] = x + i;
        B[i] = x - i;
        sa[A[i]]++;
        sb[B[i]]++;
    }

    LL res = 0;
    REP(i, N) {
        LL x = A[i];
        res += sb[-x];
        sa[x]--;
        sb[x]--;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;
int main() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 1)
            continue;
        if (a[i] % 3 == 0 || a[i] % 5 == 0) {
            continue;
        }
        return cout << "DENIED", 0;
    }
    cout << "APPROVED";
}



Measured memory_bytes: 256
var output;
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
  var one = myconv(next(),4);
  var N = one[0];
  var M = one[1];
  var X = one[2];
  var Y = one[3];
  var xlist = myconv(next(),4);
  var ylist = myconv(next(),4);
  xlist.push(X);
  ylist.push(Y);
  xlist.sort(function(a,b){
  	return a - b;
  });
  ylist.sort(function(a,b){
  	return a - b;
  });
  myerr(xlist);
  myerr(ylist);
  if(xlist[N] >= ylist[0]){
     myout("War");
  }else{
     myout("No War");
  }
  
  
}

Measured memory_bytes: 8012
#include<bits/stdc++.h>
using namespace std;
//14719021122270100109
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef unsigned long long ull;

#define f first
#define s second
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define pb eb
#define mp make_pair
#define forn(i, n) for(register int i=0; i<n; i++)
#define Forn(i, n) for(register int i=1; i<=n; i++)
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)

inline int in()
{
    char c=getchar();
    int neg=1, x=0;
    while(!isdigit(c)) (c=='-')?neg=-1, c=getchar():c=getchar();
    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48), c=getchar();
    return neg*x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int mat[]={-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int MAX=10;

int N, M, a[20005];
string dp[20005];

int main()
{
    N=in(), M=in();
    forn(i, M)
        a[i]=in();
    Forn(i, 10000)
        dp[i]="&";
    forn(i, N+1)
        forn(j, M)
        {
            if(dp[i]=="&")
                continue;
            int id=i+mat[a[j]];
            string t1=dp[id], t2=dp[i]+(char)('0'+a[j]);
            if(dp[id]=="&"||t1.size()<t2.size())
                dp[id]=t2;
            else if(t1.size()==t2.size())
                dp[id]=max(t1, t2);
        }
    cout<<dp[N]<<endl;
    return 0;
} 

Measured memory_bytes: 45056
import math
import bisect
from collections import deque
import sys
input = sys.stdin.readline


def Solve():
    L=[]
    N=int(input())
    for i in range(N):
        L.append(int(input()))

    col=1
    K=deque()
    
    
    for i,a in enumerate(L):
        if i==0:
            K.append(a)
            continue
        pos=bisect.bisect_left(K,a)
        if pos==0:
            col+=1
            K.appendleft(a)
        else:
            K[pos-1]=a

    return col



print(Solve())



Measured memory_bytes: 46940
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define int long long
#define ll long long
#define mod 998244353
#define endl "\n"
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 

using namespace std;


int32_t main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t=1,ca=0;
        //cin>>t;
        while(t--)
        {
            ca+=1;
           int a,b,c;
            cin>>a>>b>>c;
            swap(a,b);
            swap(a,c);
            cout<<a<<" "<<b<<" "<<c<<endl;
        }
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		
		if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0)
			System.out.println("Possible");
		else
			System.out.println("Impossible");
	}
}


Measured memory_bytes: 22228