akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    vector<vector<string> > s(10,vector<string>()) ;
    vector<int> num(10,0) ;
    char a[10] ={'a','b','c','d','e','f','g','h','i','j'} ;
    if (n == 1)
    {
        cout << 'a' << endl ;
    }else if (n == 2)
    {
        cout << "aa" << endl << "ab" <<endl ; 
    }else
    {
        
        num.at(0) = 1 ;
        s.at(0).push_back("a") ; 
        for (size_t i = 0; i < n-1; i++)
        {
            int ii = s.at(i).size() ;
            for (size_t j = 0; j < ii; j++)
            {
                char jj = 'a' ;
                for (size_t jjj = 0; jjj < s.at(i).at(j).size(); jjj++)
                {
                    if (s.at(i).at(j).at(jjj) > jj)
                    {
                        jj =s.at(i).at(j).at(jjj) ;
                    }
                    
                }
                
                for (size_t k = 0; k < jj - 'a' +2; k++)
                {
                    s.at(i+1).push_back(s.at(i).at(j)+a[k]) ;

                }
                
            }
            
        }
        
    }
    for (size_t i = 0; i < s.at(n-1).size(); i++)
    {
        cout << s.at(n-1).at(i) << endl ;
    }
    
    
        
}

Measured memory_bytes: 11380
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, t;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>t;
    ll count=0;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;    
        a.push_back(temp);
    }
    ll mina=a[0];
    ll maxd=0;
    for(int i=1;i<n;i++){
        if(mina>a[i]) mina=a[i];
        else if (maxd<a[i]-mina){
            maxd=a[i]-mina;
            count=1;
        }
        else if(maxd==a[i]-mina){
            count++;
        }
        else{
        }
    }
    if(count>t/2){
        cout << count << "\n";
    }
    else
    cout << count << "\n";
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  double n,k,ans;cin>>n>>k;lint i,pn,pk;ans=0;
  pn=n;pk=k;double po;int y;
  //caricurate
  int tis=0;
  for(i=1;i<=pn;i++){
   /*while(pk){
     kt+=(pk%2);
     pk/=2;
     tis++;//tis=「log2k「
   }*/
    po=1;
    y=(pk/i)+((pk%i)?1:0);
    if(y<2){tis=0;}
    else if(y<3){tis=1;}
    else if(y<5){tis=2;}
    else if(y<9){tis=3;}
    else if(y<17){tis=4;}
    else if(y<33){tis=5;}
    else if(y<65){tis=6;}
    else if(y<129){tis=7;}
    else if(y<257){tis=8;}
    else if(y<513){tis=9;}
    else if(y<1025){tis=10;}
    else if(y<2049){tis=11;}
    else if(y<4097){tis=12;}
    else if(y<8193){tis=13;}
    else if(y<16385){tis=14;}
    else if(y<32769){tis=15;}
    else if(y<65537){tis=16;}
    else{tis=17;}
    
    for(int j=0;j<tis;j++){
     po/=2;
    }
    ans+=po;
  }
  //output
  ans/=n;
  cout<<std::setprecision(18)<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(){
	char str[1024];
	char *ptr;

	gets(str);
	ptr = str;

	while(*ptr != '\0'){
		if(isalpha(*ptr)){
			putchar(*ptr-'a'+'A');
		}else{
			putchar(*ptr);
		}
		*ptr++;
	}
	putchar('\n');

	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    val xs = new Array[Int](n)
    
    for (i <- xs.indices) {
      xs(i) = sc.nextInt()
    }
    
    var ans = 1000000000
    
    for (i <- 0 until n - k + 1) {
      val y = xs(i)
      val z = xs(i + k - 1)
      val distance = math.abs(z - y)
      if (math.min(y, z) > 0) {
        ans = math.min(ans, distance + math.min(y, z))
      } else if (math.max(y, z) < 0) {
        ans = math.min(ans, distance - math.max(y, z))
      } else {
        val m = math.min(math.abs(y), math.abs(z))
        ans = math.min(ans, distance + m)
      }
    }
    
    println(ans)
  }
  
  def printArray[T](arr: Array[T]): Unit = {
    for (i <- arr.indices) {
      print(s"${arr(i)} ")
    }
    println()
  }
}


Measured memory_bytes: 52480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;
    int n[3];
    n[0] = a; n[1] = b; n[2] = c;
    sort(n, n + 3);
    
    if (c == n[1]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
/**
*    author : HikaruEgashira
*    created: 08.29.2020 21:36:00
**/
use proconio::input;

#[derive(Debug, Clone)]
enum UF {
    Root(usize),
    Child(usize),
}

#[derive(Debug)]
struct UnionFind {
    table: Vec<UF>,
}
impl UnionFind {
    // 初期化
    fn new(n: usize) -> UnionFind {
        UnionFind {
            table: vec![UF::Root(1); n],
        }
    }
    // 親
    fn root(&mut self, x: usize) -> usize {
        match self.table[x] {
            UF::Root(_) => x,
            UF::Child(parent) => {
                let root = self.root(parent);
                self.table[x] = UF::Child(root);
                root
            }
        }
    }
    // 同じグループか判定
    #[allow(dead_code)]
    fn is_same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }
    // Root(size) ← sizeの値を出力
    fn size(&mut self, x: usize) -> usize {
        let r = self.root(x);
        match self.table[r] {
            UF::Root(size) => size,
            UF::Child(_) => 0,
        }
    }
    // 併合
    fn merge(&mut self, x: usize, y: usize) {
        let root_x = self.root(x);
        let root_y = self.root(y);
        if root_x != root_y {
            let size_x = self.size(root_x);
            let size_y = self.size(root_y);
            let (i, j) = if size_x > size_y {
                (root_x, root_y)
            } else {
                (root_y, root_x)
            };
            self.table[i] = UF::Root(size_x + size_y);
            self.table[j] = UF::Child(i);
        }
    }
}

#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        a: [(usize, usize); m],
    }

    let a: Vec<(usize, usize)> = a;

    // UnionFind木の作成
    let mut uf = UnionFind::new(n);
    for mi in 0..m {
        let (x, y) = a[mi];
        uf.merge(x - 1, y - 1);
    }

    // 木の大きさの最大値を求める
    let ans = (0..n).map(|i| uf.size(i)).max().unwrap();

    println!("{}", ans);
}

#[allow(dead_code)]
fn my_ans_wa() {
    input! {
        n: usize,
        m: usize,
        a: [(usize, usize); m],
    }

    let a: Vec<(usize, usize)> = a;

    let mut group: Vec<Vec<usize>> = vec![vec![]; n];

    for (ai, bi) in a.clone() {
        for aii in group[ai - 1].clone() {
            if !group[aii - 1].contains(&bi) {
                group[aii - 1].push(bi - 1);
            }
        }
        for bii in group[bi - 1].clone() {
            if !group[bii - 1].contains(&ai) {
                group[bii - 1].push(bi);
            }
        }

        if !group[ai - 1].contains(&bi) {
            group[ai - 1].push(bi);
        }
        if !group[bi - 1].contains(&ai) {
            group[bi - 1].push(ai);
        }
    }

    let res = group.iter().map(|g| g.iter().count()).max().unwrap();

    println!("{}", res);
}


Measured memory_bytes: 10756
import sys, math
input = sys.stdin.readline

def main():
    A, B, H, M = map(int, input().split())
    a = math.pi * 2 * (((H % 12) / 12) + M / 60 / 12)
    b = math.pi * 2 * (M / 60)
    ax, ay = A * math.cos(a), A * math.sin(a)
    bx, by = B * math.cos(b), B * math.sin(b)
    print(pow((ax - bx)**2 + (ay - by)**2, 0.5))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9588
import sys
from io import StringIO
import unittest
from collections import deque
import math



def resolve():
    n, q = map(int, input().split())
    que = deque([])
    for i in range(n):
        name, time = input().split()
        name = str(name)
        time = int(time)
        que.append({'name': name, 'time': time})
    
    cur_time = 0
    while que:
        cur = que.popleft()
        if cur['time'] > q:
            cur['time'] -= q
            cur_time += q
            que.append(cur)
        else:
            cur_time += cur['time']
            print("{} {}".format(cur['name'], cur_time))

resolve()


Measured memory_bytes: 23820
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> M;
    N = 0;
    cin >> S;
    ll ans = N;
    fi(i, 0, S.size(), 1) {
    	if(S[i] == 'I') {
    		N++;
    		ans = max(ans, N);
    	}
    	else {
    		N--;
    		ans = max(ans, N);
    	}
    }
    cout << ans << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

#define ll long long
const int MOD = 1e9+7;
ll mod(ll x) {
	return (x%MOD + MOD) %MOD;
}
ll mul(ll a,ll b) {
	return mod(mod(a) * mod(b));
}

int main() {
	int n,m,k;
	cin >> n >> m >> k;
	vector<ll> a(n+1);
	vector<ll> b(m+1);
	ll sum = 0;
	for(int i = 1;i <= n;i++) {
		cin >> a[i];
		a[i] += sum;
		sum = a[i];
	}
	sum = 0;
	for(int i = 1;i<=m;i++) {
		cin >> b[i];
		b[i] += sum;
		sum = b[i];
	}
	ll j = m;ll result = 0;
	for(ll i = 0; i<= n;i++) {
		while( j >= 0 && b[j] + a[i] > k) {
			j--;
		}
		if(j == -1) break;
		result = max(result,i+j);
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 6400
n,m=map(int,input().split())
A=list(input().split())
c=[0,2,5,5,4,5,6,3,7,6]

dp=['']*(n+1)
dp[0]=''
for i in range(1,n+1):
    max=''
    for j in range(m):
        if (i-c[int(A[j])]>0 and dp[i-c[int(A[j])]]!='') or (i-c[int(A[j])]==0):
            if len(dp[i-c[int(A[j])]]+A[j])>len(max):
                max=dp[i-c[int(A[j])]]+A[j]
            elif len(dp[i-c[int(A[j])]]+A[j])==len(max) and dp[i-c[int(A[j])]]+A[j]>max:
                max=dp[i-c[int(A[j])]]+A[j]
    dp[i]=max
print(dp[n])


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

int main(void){
  string s,t; cin >> s >> t;
  int a,b; cin >> a >> b;
  string u; cin >> u;
  if(s == u) a--;
  else b--;
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
//
// Created by sark2 on 14-01-2020.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

int main() {
    IOS

    int n, k;
    cin>>n>>k;

    vector<int> p(n);
    for(int&x : p)
        cin>>x;

   vector<ld> pre(n);


    pre[0] = ((ld)p[0]+1.0)/2.0;
    for(int i = 1; i < n; i++){
        pre[i] = pre[i-1] + ((ld)p[i]+1.0)/2.0;
    }

 /*   for(int i = 0; i < n; i++){
        cout<<pre[i]<<" ";
    }
    cout<<endl;*/
    ld best = pre[k-1];
    for(int i = k; i < n; i++){
        if(pre[i]-pre[i-k] > best)
            best = pre[i] - pre[i-k];
    }


    cout<<fixed<<setprecision(12)<<best<<"\n";


}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,cnt[1000005],tot,t[1000005],ans[1005][1005],vis[1005][1005];
void dfs(int c,int x,int y)
{
	//printf("dfs(%d,%d,%d)\n",c,x,y);
	ans[x][y]=c;
	vis[x][y]=1;
	cnt[c]++;
	int nc=cnt[c]==t[c]?c+1:c;
	if(!vis[x+1][y]&&x<n)
	{
		dfs(nc,x+1,y);
		return;
	}
	if(!vis[x-1][y]&&x>1)
	{
		dfs(nc,x-1,y);
		return;
	}
	if(!vis[x][y+1]&&y<m)
	{
		dfs(nc,x,y+1);
		return;
	}
	if(!vis[x][y-1]&&y>1)
	{
		dfs(nc,x,y-1);
		return;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d",&tot);
	for(int i=1;i<=tot;i++) scanf("%d",&t[i]);
	dfs(1,1,1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) printf("%d ",ans[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 8832
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int dp[123456];
int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int>h(n);
    rep(i,n)cin >> h[i];
    rep(i,n)dp[i] = INT_MAX;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i = 2; i < n; i++){
        for(int j = 1; j <= k and i-j>=0; j++)dp[i] = min(dp[i-j] + abs(h[i]-h[i-j]),dp[i]);
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N, M , K; cin >> N >> M >> K;
    bool t = true;
    for(int i=0; i<=N; i++){
        if(t){
        for(int j=0; j<=M; j++){
            if(M*i + N*j - 2*i*j == K){
                cout << "Yes";
                t = false;
                break;
            }
        }
        }
    }
    if(t){
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define DEBUG

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef pair<long,long> pr;
typedef map<double,pr> mp;
typedef long long LL;

string s;
char t;
int main ()
{
    REP(i, 3){
        REP(j, 3){
            cin >> t;
            if (j == i)
                cout << t;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  vector<char> a;
  REP(i, s.size()){
    if(s[i] == 'B'){
      if(a.size() != 0) a.pop_back();
      continue;
    }
    a.push_back(s[i]);
  }
  REP(i, a.size()) cout << a[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N, M, C = sc.nextInt
  val B = Array.fill(M)(sc.nextInt)
  val A = Array.fill(N, M)(sc.nextInt)

  val x = (0 until N).map(i => {
    (A(i) zip B).foldLeft(0)((z, ab) => ab._1 * ab._2 + z) + C
  }).count(_ > 0)

  println(x)
}


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

int main() {
  int a;cin>>a;
  cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3620
from itertools import accumulate
n = int(input())
a = list(map(int,input().split()))
a.sort()
ac = list(accumulate(a))
a.reverse()
ac.reverse()
p = [0] * n
p[0] = 1
for i in range(1,n):
  if a[i-1] <= ac[i] * 2:
    p[i] = p[i-1]
print(sum(p))

Measured memory_bytes: 64616
#include<iostream>
using namespace std;
int main(){
    int N,Y;
    int a,b,c;
    int x,y;
    bool flag = false;
    cin >> N >> Y;
    Y /= 1000;
    a = Y/10;
    while(a >= 0 && a <= N){
        x = Y - 10*a;
        y = N - a;
        if(x >= y && x <= 5*y && (x-y)%4 == 0){
            b = (x-y)/4;
            c = y-b;
            flag = true;
            break;
        }
        a--;
    }
    if(flag) cout << a << ' ' << b << ' ' << c << endl;
    else cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n;
set<ll>st;
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
inline void check(ll kk)
{
	ll cur=n;
	while(cur%kk==0)
	{
		cur/=kk;	
	} 
	cur%=kk;
	if(cur==1)
	{
		st.insert(kk);
	}
}
int main()
{
	n=read();
	if(n==2)
	{
		return puts("1"),0;
	}
	for(register int i=1;i<=sqrt(n-1);i++)
	{
		if((n-1)%i==0)
		{
			if(i!=1)
			{
				st.insert(i);
			}
			st.insert((n-1)/i);
		}
	}
	for(register int i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			if(i!=1)
			{
				check(i);
			}
			check(n/i);
		}
	}
	printf("%d\n",st.size());
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
void resolver();
inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
template <class T>
inline std::vector<T> read_vector()
{
    ll n;
    std::cin >> n;
    std::vector<T> ret(n);
    for (T &i : ret) {
        std::cin >> i;
    }
    return ret;
}
void t_case()
{
    ll t;
    std::cin >> t;
    while (t--) {
        resolver();
    }
}
void single_case()
{
    resolver();
}

int main(int argc, char *argv[])
{
    fast_io();
    // t_case();
    single_case();
}

void resolver()
{
    ll n;
    string s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    cin >> n >> s;
    ll num = 0;
    for (ll i = 0; i < n; i++) {
        if (s[i] == 'R')
            r.push_back(i + 1);
        if (s[i] == 'G')
            g.push_back(i + 1);
        if (s[i] == 'B')
            b.push_back(i + 1);
    }
    for (auto i : r)
        for (auto j : g)
            for (auto k : b) {
                if (2 * j == i + k)
                    continue;
                if (2 * k == i + j)
                    continue;
                if (2 * i == j + k)
                    continue;
                num++;
            }
    cout << num;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

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

int main(){
    int N; cin >> N;
    vector<int> ans;

    for(int i=6; i<=55555; i+= 5){
        if(isPrime(i)) ans.push_back(i);
        if(ans.size() == N) break;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+7;

ll inv[maxn],finv[maxn],f[maxn];
int n,k;
int tot[maxn];

void init() //inv,f,finv 都开ll
{
    inv[1] = 1;
    for (int i = 2; i < maxn; i++)
        inv[i] = (mod - mod / i) * inv[mod % i] % mod; //inv: 逆元
    f[0] = finv[0] = 1;                                //f: 阶乘    finv:阶乘逆元(1/f)
    for (int i = 1; i < maxn; i++)
    {
        f[i] = f[i - 1] * i % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll C(int n, int m) //C(n,m)
{
    if (m < 0 || m > n)
        return 0;
    return f[n] * finv[n - m] % mod * finv[m] % mod;
}
int main()
{
    init();
    cin>>k>>n;
    for(int i=2;i<=2*k;++i)
    {
        int cnt;
        if(i&1)
        {
            if(i<=k+1) cnt=(i-1)/2;
            else cnt=(2*k-i+1)/2;  
        }
        else
        {
            if(i<=k+1) cnt=(i/2);
            else cnt=(2*k-i)/2+1;
        }
        //dbg(cnt);
        int ans=0; 
        for(int j=0,d=1;j<=cnt&&j+j<=n;++j,d=mod-d)
            ans=(ans+d*C(cnt,j)%mod*C(n-2*j+k-1,k-1))%mod;
        print(ans);
    }

}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

using Graph = VVI;
bool visit(const Graph& G, int v, VI& order, VI& color){
  color[v] = 1;
  for(int i=0;i<SZ(G[v]);++i){
	int to = G[v][i];
	if(color[to] == 2) continue;
	if(color[to] == 1) return false;
	if(!visit(G, to, order, color)) return false;
  }
  order.push_back(v);
  color[v] = 2;
  return true;
}

bool topo_sort(const Graph& G, VI& order){
  int N = G.size();
  VI color(N, 0);

  REP(u,N)
	if(!color[u] && !visit(G, u, order, color))
	  return false;
  reverse(ALL(order));
  return true;
}

bool uniq(Graph G_){
  int N = SZ(G_);
  VI in(N);
  Graph G(N);
  REP(i,N)
	for(int to: G_[i]){
	  G[to].PB(i);
	  in[i]++;
	}

  queue<int> q;
  REP(i,N)
	if(in[i] == 0){
	  q.push(i);
	}
  while(!q.empty()){
	if(SZ(q) > 1) return false;
	int u = q.front();
	q.pop();
	for(int to: G[u]){
	  if(--in[to] == 0){
		q.push(to);
	  }
	}
  }
  return true;
}

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

  int N, M;
  cin >> N >> M;
  VVI G(N);
  REP(i,M){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	G[u].PB(v);
  }
  VI order;
  topo_sort(G, order);
  REP(i,N) cout << order[i]+1 << endl;
  cout << (uniq(G)? 0: 1) << endl;

  return 0;
}

Measured memory_bytes: 5356
// doot diddly donger cuckerino Hahahahahah


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

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

const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

class DDiceInLine {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n, k;
    cin >> n >> k;
    vector<ld> p(n);
    for (int i = 0; i < n; ++i) {
      cin >> p[i];
    }
    auto val = [&](int id) -> ld {
      return (p[id] + 1) / (ld) 2;
    };
    ld now = 0;
    for (int i = 0; i < k; ++i) {
      now += val(i);
    }
    ld ans = now;
    for (int i = k; i < n; ++i) {
      now -= val(i - k);
      now += val(i);
      maxi(ans, now);
    }
    cout << fixed << setprecision(12) << ans << '\n';
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	DDiceInLine solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6344
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N; cin>>N;
    vi A(N),B(N),C(N-1);
    rep(i,N) cin>>A.at(i);
    rep(i,N) cin>>B.at(i);
    rep(i,N-1) cin>>C.at(i);
    int counter=0;
    rep(i,N) counter+=B.at(i);
    rep(i,N-1) {
        if(A.at(i)+1==A.at(i+1)) {
            counter+=C.at(A.at(i)-1);
        }
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

char primes[150][150];

int main(){ _;
  primes[0][0]=primes[0][1]='C';
  primes[1][1]='P';
  for(int p=2;p<=141;p++){
    for(int q=0;q<=p&&p*p+q*q<=20000;q++){
      for(int m=-p;m<=p;m++){
	for(int n=-p;n<=p;n++){
	  if(m*m<n*n)continue;
	  if(m*m==p*p&&n*n==q*q)continue;
	  int m2n2=m*m+n*n;
	  if(m2n2<=1)continue;
	  int mpnq=m*p+n*q;
	  int mqnp=m*q-n*p;
	  if(mpnq%m2n2==0&&mqnp%m2n2==0){
	    primes[p][q]='C';
	    goto EXIT;
	  }
	}
      }
      primes[p][q]='P';
    EXIT:;
    }
  }
  int queries; cin>>queries;
  REP(q,queries){
    int m,n; cin>>m>>n;
    if(m<0)m=-m;
    if(n<0)n=-n;
    if(m<n)swap(m,n);
    cout<<primes[m][n]<<endl;
  }
}

Measured memory_bytes: 3148
def solve(ms, total):
    d = sum(ms)
    a = total - d
    m = min(ms)
    return len(ms) + (a // m)
   
if __name__ == '__main__':
    n, total = input().split()
    n = int(n)
    total = int(total)

    ms = []
    for x in range(n):
        m = int(input())
        ms.append(m)

    print(solve(ms, total))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int find(string str[],int n,int m,int mask,int mask1)
{
    int ans=0;
    int vis[n][m]={};
    for(int i=0;i<n;i++)
    {int x=1<<i;
    if(mask&x)
    {
        for(int j=0;j<m;j++)
           vis[i][j]=1;
    }
    }
    for(int i=0;i<m;i++)
    {
        int x=1<<i;
        if(mask1&x)
        {
            for(int j=0;j<n;j++)
            {
                vis[j][i]=1;
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(str[i][j]=='#'&&!vis[i][j])
            {
                ans++;
            }
        }
    }
    return ans;
}
void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    string str[n];
    for(int i=0;i<n;i++)
        cin>>str[i];
        int ans=0;
    for(int i=0;i<(1<<n);i++)
    {
        for(int j=0;j<(1<<m);j++)
        {
            int mask=i;
            int mask1=j;
            int x=find(str,n,m,mask,mask1);
            if(x==k)
                ans++;
        }
    }
    cout<<ans<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <bits/stdc++.h>
#define INF 1555889
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define endl "\n"
#define M(a, b) (a + b) / 2
#define L(x) 2 * x
#define R(x) 2 * x + 1
#define pb(a) push_back(a)
#define MOD 1000000000
#define f(x,a,b) for(ll x=a;x<=b;x++)
using namespace std;
typedef pair<ll, ll> ii;
typedef pair<ll, vector<ll > > iv;
typedef pair<ll, ii> iii;
ll Move[8][2] = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 }, { 1, 1 }, { -1, 1 }, { 1, -1 }, { -1, -1 } };
void sync()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
/*
    comment??
    nothing at all
    ah oui bien sure
    fuck you bitch
    fils de pute
*/
char origine[105][105],cop[105][105];
int n;
void _new(){
    ms(origine,'#');
    ms(cop,'#');
    return ;
}
/*
           ^
           |
   ------------------
   |global variables|
   ------------------
*/
int  main()
{
    //ofstream cout("tst1.txt",ofstream::out);
    //ifstream cin("tst.txt",ifstream::in);
    int n;
    cin>>n;
    int a[n+5],m[n+5],b[n+5];
    ms(m,0);
    ms(b,0);
    f(i,1,n){
        cin>>a[i];
    }
    bool impossible=false;
    vector<int>v;
    for(int i=n;i>=1;i--){
        if(a[i]==m[i])continue;
        for(int j=1;j*j<=i;j++){
            if(i%j==0){
                m[j]=(m[j]+1)%2;
                if(i/j!=j)
                    m[i/j]=(m[i/j]+1)%2;
            }
        }
        b[i]=(b[i]+1)%2;
        if(b[i]==1)v.pb(i);

    }
    cout<<v.size()<<endl;
    for(auto y:v)cout<<y<<" ";



}
/*
4 3
4 4 4 4
1 2
2 3
3 4
4
1 2 3 4
0 0*/


Measured memory_bytes: 6188
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int H = stdIn.nextInt();
		int A = stdIn.nextInt();
		int i=0;
		while(H>0) {
			H -= A;
			i++;
		}
		System.out.println(i);
	}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <cmath>
using namespace std;
#define fio ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int N,M;
int main() {
	scanf("%d", &N);
	int ans = 0;
	for (int i = 1;i <= N;i+=2) {
		int ret = 0;
		for (int j = 1;j <= i;j++) {
			if ((i%j) == 0) 
				ret++;
		}
		if (ret == 8) {
			ans++;
		}
	}
	printf("%d", ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD =1000000007;//1e9 + 7;




int main(){
	ll n,m;
	cin>>n>>m;
	if(n*500>=m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

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

#define rep(i, a) for (int i = 0; i < (int) a; i++)
#define all(v) (v).begin(), (v).end()

 
signed main()
{
	int N, L;
	cin >> N >> L;
	vector<string> v(N);
	rep(i, N) cin >> v[i];
	sort(all(v));
	for (string s : v) cout << s;
	cout << endl;
}
 


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

const ll N=200010,MOD=998244353;
ll n,Q;
ll mod[11][N],power[N];

struct Segtree
{
	ll l[N*4],r[N*4],lazy[N*4];
	ll sum[N*4];
	
	void build(ll x,ll ql,ll qr)
	{
		l[x]=ql; r[x]=qr;
		if (ql==qr)
		{
			sum[x]=1;
			return;
		}
		ll mid=(ql+qr)>>1;
		build(x*2,ql,mid); build(x*2+1,mid+1,qr);
		sum[x]=(sum[x*2]*power[r[x*2+1]-l[x*2+1]+1]%MOD+sum[x*2+1])%MOD;
	}
	
	void pushdown(ll x)
	{
		if(lazy[x])
		{
			ll v=lazy[x]; lazy[x]=0;
			sum[x*2]=mod[v][r[x*2]-l[x*2]+1];
			sum[x*2+1]=mod[v][r[x*2+1]-l[x*2+1]+1];
			lazy[x*2]=lazy[x*2+1]=v;
		}
	}
	
	void update(ll x,ll ql,ll qr,ll v)
	{
		if (l[x]==ql && r[x]==qr)
		{
			sum[x]=mod[v][qr-ql+1];
			lazy[x]=v;
			return;
		}
		pushdown(x);
		ll mid=(l[x]+r[x])>>1;
		if (qr<=mid) update(x*2,ql,qr,v);
		else if (ql>mid) update(x*2+1,ql,qr,v);
		else update(x*2,ql,mid,v),update(x*2+1,mid+1,qr,v);
		sum[x]=(sum[x*2]*power[r[x*2+1]-l[x*2+1]+1]%MOD+sum[x*2+1])%MOD;
	}
}seg;

int main()
{
	scanf("%lld%lld",&n,&Q);
	power[1]=10;
	for (ll i=2;i<=n;i++)
		power[i]=power[i-1]*10%MOD;
	for (ll i=1;i<=9;i++)
	{
		mod[i][1]=i;
		for (ll j=2;j<N;j++)
			mod[i][j]=(mod[i][j-1]*10+i)%MOD;
	}
	seg.build(1,1,n);
	while (Q--)
	{
		ll ql,qr,x;
		scanf("%lld%lld%lld",&ql,&qr,&x);
		seg.update(1,ql,qr,x);
		printf("%lld\n",seg.sum[1]);
	}
	return 0;
}

Measured memory_bytes: 35856
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define endl endl;cf
#define be begin()
#define sz size()
#define en end()
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define rngx mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define cf cout.flush()
int main()
{
    ios;
    ll n ;
    cin >> n ;
    vl v;
    forn( i , 1,  n)
    {
        ll x;
        cin >> x;
        v.pb(x);
    }
    ll gcd = __gcd(v[0] , v[1]);
    for(ll i =2 ; i <n;++i){
        gcd = __gcd(gcd , v[i]);
    }
    cout << gcd <<endl;
}


Measured memory_bytes: 1400
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
 
H,W = map(int,input().split())
 
table = [[0]*(W+1) for i in range(H+1)]
 
for row in range(H):
    work = list(map(int,input().split())) #★★直にtableに代入すると、列数が変わってしまう!!!
    for col in range(W):
        table[row][col] = work[col]
 
 
for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]
 
 
for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]
 
 
for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6220
n,x,m=map(int,input().split())
a=[]
mod_check_list = [False for _ in range(m)]
a.append(x*x%m)
ind=0
s=0
for i in range(m):
    t=a[i]*a[i]%m
    if mod_check_list[t]:
        ind=a.index(t)
        break
    mod_check_list[t] = True
    a.append(t)
s=sum(a[ind:])
l=len(a)-ind
loop_times = (n-1-ind)//l
answer=loop_times*s
for i in range((n-1-ind)%l):
    answer+=a[i+ind]
print(answer+x+sum(a[:ind]))

Measured memory_bytes: 12172
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<int> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }

    // int ans = 0;

    int a, b;
    cin >> a >> b;

    if (a <= b)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }

    // cout << ans << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3696
s=input()
d="ATGC"
m=0;r=""
for i in range(len(s)):
    for j in range(i,len(s)):
        if s[j] not in d:break
        else:
            if j-i+1>m:m=j-i+1;r=s[i:j+1]
print(m)

Measured memory_bytes: 2940
s = input()
x = 0
y = 0

check = "0"
for i in range(len(s)):
  if s[i] != check:
    x += 1
  if check == "0":
    check = "1"
  else:
    check = "0"
check = "1"
for j in range(len(s)):
  if s[j] != check:
    y += 1
  if check == "0":
    check = "1"
  else:
    check = "0"
  
if x<=y:
  ans = x
else:
  ans = y
print(ans)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC168_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            n = n % 10;

            if (n == 2 ||
                n == 4 ||
                n == 5 ||
                n == 7 ||
                n == 9)
            {
                Console.WriteLine("hon");
            }
            else if (n == 0 ||
                     n == 1 ||
                     n == 6 ||
                     n == 8)
            {
                Console.WriteLine("pon");
            }
            else if (n == 3)
            {
                Console.WriteLine("bon");
            }
        }
    }
}


Measured memory_bytes: 27520
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H==0 && W==0) {
				break;
			}
			for(int i=0;i<W;i++) {
			System.out.print("#");
			}System.out.printf("\n");
			for(int k=0;k<H-2;k++) {
				System.out.print("#");
				for(int j=0;j<W-2;j++) {
					System.out.print(".");
				}System.out.printf("#\n");
			}
			for(int i=0;i<W;i++) {
				System.out.print("#");
			}
				
				
				System.out.println("\n");
			}
		
		sc.close();
		}
		
	
}



Measured memory_bytes: 32980
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

// ans の m 行目の l~k が全部空白なら num にする
bool replace(vector<vector<int>>& ans, int m, int l, int r, int num) {
  bool flag = true;
  for (int i = l; i <= r; i++) {
    if (ans[m][i] != 0) {
      flag = false;
      break;
    }
  }
  if (flag) for (int i = l; i <= r; i++) ans[m][i] = num;
  return flag;
}

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<vector<int>> ans(h, vector<int>(w));

  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      if (s[j] == '.') ans[i][j] = 0;
      else {
        ans[i][j] = INF;
      }
    }
  }

  int num = 0;
  rep(i, h) {
    int l = 0;
    int r = 0;
    rep(j, w) {
      if (0 < ans[i][j] && ans[i][j] < INF) {
        l = j+1;
      } else if (ans[i][j] == INF) {  // いちご発見
        num++;
        r = j;
        for (int k = j+1; k < w; k++) {  // r を決める
          if (ans[i][k] == 0) r = k;
          else break;
        }
        j = r;
        // l から r までを ans[i][j] の領地にする
        for (int k = l; k <= r; k++) ans[i][k] = num;
        for (int m = i-1; m >= 0; m--) {
          if (!replace(ans, m, l, r, num)) break;
        }
        for (int m = i+1; m < h; m++) {
          if (!replace(ans, m, l, r, num)) break;
        }
        l = r+1;
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }

  return 0;
}


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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int res[10000];

int main(){
  int i,j,k,n;
  int d;

  while(scanf("%d",&n) != EOF){
    res[0] = 2; d = 2;
    REP(i,1,n){
      res[i] = res[i-1] + d;
      d++;
    }
    printf("%d\n",res[n-1]);
  }

  return 0;
}

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

int main(void) {
	int n; cin >> n;

	if (n >= 64) {
		cout << "64" << endl;
	}
	else if (n >= 32) {
		cout << "32" << endl;
	}
	else if (n >= 16) {
		cout << "16" << endl;
	}
	else if (n >= 8) {
		cout << "8" << endl;
	}
	else if(n >= 4) {
		cout << "4" << endl;
	}
	else if (n >= 2) {
		cout << "2" << endl;
	}
	else { cout << "1" << endl; }
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	if(n%1000!=0)
	cout<<1000-n%1000<<endl;
	else
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 3628
while True:                                                                                      
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    countl = 0

    while True:
        if W == 0:
            break
        if countl == H:
            break
        elif countl % 2 == 0:
            countll = 0
            while True:
                if countll % 2 == 0:
                    print('#', end='')
                    countll += 1
                else:
                    print('.', end='')
                    countll += 1
                if countll == W:
                    print()
                    break
        elif countl % 2 == 1:
            countll = 0
            while True:
                if countll % 2 == 0:
                    print('.', end='')
                    countll += 1
                else:
                    print('#', end='')
                    countll += 1
                if countll == W:
                    print()
                    break
        countl += 1
    print()

Measured memory_bytes: 8992
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		int[] dp = new int[N];
		dp[0] = 0;
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		dp[1] = Math.abs(h[1] - h[0]);
		for(int i = 1;i < N - 1;i++){
			int jump = Math.abs(h[i + 1] - h[i]);
			int highJump = Math.abs(h[i + 1] - h[i - 1]);
			dp[i + 1] = Math.min(jump + dp[i],highJump + dp[i - 1]);
		}
		System.out.println(dp[N-1]);
	}
}

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

int main() {
  int a,b; cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3636