akhauriyash/Code-Regression huggingface dataset:
#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字くらい使った方がいいかも
*/

int main(){
    
    char x, y; cin >> x >> y;
    if(x < y) cout << '<' << endl;
    else if(x > y) cout << '>' << endl;
    else cout << '=' << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
res = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        res += 1
print(res)

Measured memory_bytes: 9124
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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)*}
    };
}

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn gcd(mut x: i64, mut y: i64) -> i64 {
    while y != 0 {
        let r = x % y;
        x = y; y = r;
    }
    x
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        x: [i64]
    }
    let mut g = 0;
    for x in x {
        g = gcd(g, x);
    }
    puts!("{}\n", g);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> vec;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		vec.emplace_back(make_pair(a, b));
	}
	sort(vec.begin(), vec.end());
	int co = 1;
	int l = vec[0].first, r = vec[0].second;
	for (int i = 1; i < m; i++) {
		if (r <= vec[i].first) {
			co++;
			l = vec[i].first;
			r = vec[i].second;
		}
		if (r > vec[i].second) {
			r = vec[i].second;
		}
		if (l < vec[i].first) {
			l = vec[i].first;
		}
	}
	cout << co << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[5];
  char a[5] = "abc";
  char b[5] = "acb";
  char c[5] = "bac";
  char d[5] = "bca";
  char e[5] = "cab";
  char f[5] = "cba";
	scanf("%s", s);

  if (strcmp (s, a) == 0 || strcmp (s, b) == 0 || strcmp (s, c) == 0 || strcmp (s, d) == 0 || strcmp (s, e) == 0 || strcmp (s, f) == 0) {
    printf("Yes\n");
  } else {
  printf("No\n");
  }

return 0;
}

Measured memory_bytes: 128
import sys


class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y



def direction_of_rotation(p1, p2, p3):
    d = p1.x * (p2.y - p3.y) + p2.x * (p3.y - p1.y) + p3.x * (p1.y - p2.y)
    if d < 0:
        direction = 'right'
    else:
        direction = 'left'
    return direction



#input_file = open(sys.argv[1], "r")

#for line in input_file:
for line in sys.stdin:
    a = map((lambda x: float(x)), line.split(' '))
    p1 = Point(a[0], a[1])
    p2 = Point(a[2], a[3])
    p3 = Point(a[4], a[5])
    p  = Point(a[6], a[7])
    d1 = direction_of_rotation(p, p1, p2)
    d2 = direction_of_rotation(p, p2, p3)
    d3 = direction_of_rotation(p, p3, p1)
    if d1 == d2 and d1 == d3:
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 4276
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n,m;

    cin>>n>>m;

    priority_queue<int>Q;

    int i;
    for(i=0;i!=n;i++)
    {
        int x;
        cin>>x;

        Q.push(x);
    }

    i = 0;
    while(i < m)
    {
        int p = Q.top();
        Q.pop();

        p = p >> 1;

        Q.push(p);
        i++;
    }

    ll s = 0;
    while(!Q.empty())
    {
        s += Q.top();
        Q.pop();
    }

    cout<<s;

    return 0;
}

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define inf LLONG_MAX
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
#define mod 998244353
typedef  long long ll; 
typedef  unsigned long long ull; 
//using u64 = uint64_t; 
//using u128 = __uint128_t;
typedef vector< ll > edge; 
typedef pair< ll , bool > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll N=1e5+20;

int main()
{
	boost;
	ll m,k;
	cin>>m>>k;
	ll mask=1ll<<m;
	//check(mask);
	if(m==0)
	{
		if(k==0) cout<<"0 0";
		else cout<<"-1";
		return 0;

	}
	if(m==1)
	{
		if(k==0) cout<<"0 1 1 0";
		else  cout<<"-1";
		return 0;
	}
	if(k>=mask) 
	{
		cout<<"-1";
		return 0;
	}
	for(ll i=0;i<mask;i++)
	{
		if(i!=k) cout<<i<<" ";
	}
	cout<<k<<" ";
	for(ll i=mask-1;i>=0;i--)
	{
		if(i!=k) cout<<i<<" ";
	} 
	cout<<k;

	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001

unordered_set <int> adj[maxn];
int sz[maxn];
int p[maxn];
int N,M,K;

int fL(int x){
	if (p[x] == -1) return x;
	return p[x] = fL(p[x]);
}

void join(int a,int b){
	a = fL(a); b = fL(b);
	
	if (a == b) return;
	
	sz[b] += sz[a];
	p[a] = b;
}
int main(){
	fast;
	
	mem(p,-1);
	
	cin>>N>>M>>K;
	
	FOR(i,1,N) sz[i] = 1;
	
	FOR(i,0,M-1){
		int a,b;
		cin>>a>>b;
		join(a,b);
		adj[a].insert(b);
		adj[b].insert(a);
	}
	
	FOR(i,0,K-1){
		int a,b;
		cin>>a>>b;
		
		adj[a].insert(b);
		adj[b].insert(a);
	}
	

	
	FOR(i,1,N){
		int ans = sz[fL(i)] - 1;
		
		aFOR(j,adj[i]){
			if (fL(j) == fL(i)){
				ans--;
			}
		}
		
		
		cout<<ans<<' ';
	}
}



Measured memory_bytes: 26404
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:56:48 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

X = int(input())

for i in range(-5000,5001):
    for j in range(-5000,5001):
        if pow(i,5) - pow(j,5) == X:
            print(i,j)
            sys.exit()



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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    LL n,m;
    cin >> n >> m;
    if (n == 1 and m == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (n == 1 or m == 1) {
        cout << max(n,m) - 2 << endl;
        return 0;
    }
    if (n == 2 or m == 2) {
        cout << 0 << endl;
        return 0;
    }

    cout << (n-2)*(m-2) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
 
	int n,p;
	while(cin>>n>>p,n||p){
		vector<int> v(n);
		int i = 0;
		int w = p;
		for(;i < 1000000+1; i++){
			if(p){
				v[i%n]++;
				p--;
			}else {
				p = v[i%n];
				v[i%n] = 0;
			}

			if(p==0&&v[i%n]==w) break;
		}

		cout << i%n << endl;
	}
    return 0;
}

Measured memory_bytes: 1196
M = "UNRESTORABLE"
Sd = gets.chomp
T = gets.chomp
ans = []

(0..(Sd.length - T.length)).each do |i|
  s = Sd.dup
  f = true
  T.chars.each.with_index do |c, j|
    if Sd[i+j] != "?" && Sd[i+j] != c
      f = false
      break
    else
      s[i+j] = c
    end
  end
  next unless f
  ans << s.tr("?", "a")
end

if ans.empty?
  puts M
else
  puts ans.sort.first
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int n,k; cin >> n >> k;
	string s; cin >> s;
	k--;
	s[k] = s[k] + 0x20;
	cout << s << endl;
}




Measured memory_bytes: 256
def min_disc(points):
    from random import sample
    N = len(points)
    if N == 1:
        return points[0], 0
    points = sample(points, N)
    def cross(a, b):
        return a.real * b.imag - a.imag * b.real
    def norm2(a):
        return a.real * a.real + a.imag * a.imag
    def make_circle_3(a, b, c):
        A, B, C = norm2(b-c), norm2(c-a), norm2(a-b)
        S = cross(b-a, c-a)
        p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S)
        radius = abs(p-a)
        return p, radius
    def make_circle_2(a, b):
        c = (a+b) / 2
        radius = abs(a-c)
        return c, radius
    def in_circle(point, circle):
        return abs(point-circle[0]) <= circle[1]+1e-7
    p0 = points[0]
    circle = make_circle_2(p0, points[1])
    for i, p_i in enumerate(points[2:], 2):
        if not in_circle(p_i, circle):
            circle = make_circle_2(p0, p_i)
            for j, p_j in enumerate(points[1:i], 1):
                if not in_circle(p_j, circle):
                    circle = make_circle_2(p_i, p_j)
                    for p_k in points[:j]:
                        if not in_circle(p_k, circle):
                            circle = make_circle_3(p_i, p_j, p_k)
    return circle

N = int(input())
XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append(x + y*1j)
center, rad = min_disc(XY)
print(rad)


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int cnt = 0;
    vector<int>vis(30, 0);
    for(int i = 0; i < s.size(); i++){
        if(vis[s[i] - 'a'] == 0){
            vis[s[i] - 'a'] = 1;
            cnt++;
        }
    }
    if(cnt == 2){
        cout << "Second";
        return 0;
    }
    int n = s.size();
    if(s[0] == s[n - 1]){
        if(n % 2 == 1){
            cout << "Second";
        }
        else{
            cout << "First";
        }
        return 0;
    }
    if(n % 2 == 1){
        cout << "First";
    }
    else{
        cout << "Second";
    }
    return 0;
}

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

int main(){

    string a, b, c; cin >> a >> b >> c;
    int lena = (int)a.size();
    int lenb = (int)b.size();

    if(a[lena - 1] == b[0] && b[lenb - 1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


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

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

d5 = 0
d7 = 0

for i in n:
    if i == 5:
        d5 += 1
    elif i == 7:
        d7 += 1
 
if d5 == 2 and d7 == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;
  cin>>n>>w;
  long long int w1[n],v1[n];
  long long int arr[n+1][w+1];
  for(int i=0;i<n;i++){
cin>>w1[i]>>v1[i];
  }
  for(int i=0;i<=n;i++){
  for(int j=0;j<=w;j++){
  if(i==0||j==0){
  arr[i][j]=0;
  }
    else if(w1[i-1]<=j){
    arr[i][j]=max(v1[i-1]+arr[i-1][j-w1[i-1]],arr[i-1][j]);
    }
    else{
    arr[i][j]=arr[i-1][j];
    }
  }
    
  }
  cout<<arr[n][w];
return 0;
}

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

int main() {
    string s;
    cin >> s;

    // 必要十分条件
    // s1 = 1 葉は必ず存在する
    // sn = 0 枝を切った場合必ずn以下になる
    // si = sn-i 対称性

    int n = s.size();

    // 先頭に0を足す
    s = "0" + s;

    if (s.at(1) == '0') {
        cout << -1 << endl;
        return 0;
    }
    if (s.at(n) == '1') {
        cout << -1 << endl;
        return 0;
    }
    // si = sn-1を確認
    for (int i = 1; i <= n/2+1; i++) {
        if (s.at(i) != s.at(n-i) ) {
            cout << -1 << endl;
            return 0;
        }
    }

    // treeを作成
    int f = 1;
    for (int i = 1; i < n; i++) {
        cout << f << ' ' << i+1 << endl;
        if (s.at(i) == '1') f = i+1;
    }

}

Measured memory_bytes: 1660
# -*- coding: utf-8 -*-
import math
import random
import time
import numpy as np

start = time.time()
limit_time = 1.8

# 整数の入力
d = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for j in range(d)]

c_num = np.array(c)
s_num = np.array(s)

# d_map = {i: [] for i in range(d)}

def point(t):
    result = 0
    map = {
        0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,
        10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0,
        20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0
    }
    for i in range(d):
        comp = t[i] - 1
        day = i + 1
        map[comp] = day
        # d_map[comp].append(day)
        result = result + s[i][comp]
        for cc in range(26):
            result = result - c[cc] * (day - map[cc])
    return result

t = np.argmax(s_num, axis=1) + 1
# t = [int(input()) for i in range(d)]

p = point(t)

# m = int(input())

# for i in range(m):
#     [d, q] = input().split()
#     list = d_map[d - 1]
#     old_q = t[d - 1]
#     index = np.searchsorted(list, d)
#
#     t[d - 1] = q


while time.time() - start < limit_time:
    new_d = math.floor(d * random.random())
    old_t = t[new_d]
    t[new_d] = math.floor(26 * random.random()) + 1
    new_p = point(t)
    if p < new_p:
        p = new_p
    else:
        t[new_d] = old_t

print("\n".join([str(i) for i in t]))



Measured memory_bytes: 27388
#include <iostream>
#include<map>
using namespace std;
typedef long long ll;
ll n,s[26],d[365][26],t[365],ans,u[26],q,a,b,MAX=-10000000,L,A[365];
int main(void){
    cin>>n;
    for(int i=0;i<26;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            cin>>d[i][j];
        }
    }
    for(int i=0;i<n;i++){cin>>t[i];}
    
    
    
    q=26;
    while(q--){
        ans=0;
        for(int i=0;i<26;i++)u[i]=0;
        
        for(int i=0;i<n;i++){
            t[i]=(q+i)%26+1;
        }
        
        for(int i=0;i<n;i++){
            ans+=d[i][t[i]-1];
            u[t[i]-1]=i+1;
            for(int j=0;j<26;j++){
                ans-=s[j]*(i+1-u[j]);
            }
        }
        if(MAX<ans){
            MAX=ans;
            for(int i=0;i<n;i++){
                A[i]=t[i];
            }
        }
    }
    
    for(int i=0;i<n;i++){
        cout<<A[i]<<endl;
    }
}


Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vvi a(n + 1, vi(m + 1));
	int all_sum = 0;
	rep(i, n) {
		rep(j, m) {
			cin >> a[i][j];
			all_sum += a[i][j];
		}
	}

	rep(i, n) {
		int rsum = 0;
		rep(j, m) {
			rsum += a[i][j];
		}
		a[i][m] = rsum;
	}

	rep(i, m) {
		int sum = 0;
		rep(j, n) {
			sum += a[j][i];
		}
		a[n][i] = sum;
	}

	a[n][m] = all_sum;

	rep(i, n + 1) {
		rep(j, m + 1) {
			cout << a[i][j];
			if (j + 1 != m + 1) cout << " ";
		}
		cout << endl;
	}

}


Measured memory_bytes: 3172
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
int main()
{
    string a, b , c;
    cin >> a >> b >> c;
    if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;;
    return 0;
}

Measured memory_bytes: 384
from math import radians, cos, sin


if __name__ == '__main__':
    # ??????????????\???
    directions = []
    while True:
        distance, rotation = [int(x) for x in input().strip().split(',')]
        if distance == 0 and rotation == 0:
            break
        else:
            directions.append((distance, rotation))

    # ???????????????
    my_x = 0
    my_y = 0
    my_d = 90
    for d in directions:
        my_x += d[0] * cos(radians(my_d))
        my_y += d[0] * sin(radians(my_d))
        my_d -= d[1]

    # ???????????????
    print('{0}\n{1}'.format(int(my_x), int(my_y)))

Measured memory_bytes: 7884
#include<bits/stdc++.h>
	#define llu unsigned long long
	#define ll long long
	#define INF 0x3f3f3f3f
	#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define endl "\n"

	using namespace std;
	ll binomialCoeff(ll n, ll k) 
	{ 
	    ll C[k+1]; 
	    memset(C, 0, sizeof(C)); 
	  
	    C[0] = 1; 
	  
	    for (ll i = 1; i <= n; i++) 
	    { 
	        for (ll j = min(i, k); j > 0; j--) 
	            C[j] = C[j] + C[j-1]; 
	    } 
	    return C[k]; 
	}  
	int main()
	{
		fast
		ll N;
		cin>>N;
		ll arr[N];
		map<ll,ll> mp;
		for(ll i=0; i<N; i++)
		{
			cin>>arr[i];
			mp.insert({arr[i],0});
		}
		for(ll i=0; i<N; i++)
		{
			mp[arr[i]]++;
		}
		ll ans=0;
		for(ll i=0; i<mp.size(); i++)
		{
			ans+=binomialCoeff(mp[i],2);
		}
		for(ll i=0; i<N; i++)
		{
			cout<<(ans-mp[arr[i]]+1)<<endl;
		}
	}

Measured memory_bytes: 16384
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

string s[maxn];
ll a[3];
int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n>>a[0]>>a[1]>>a[2];
  for(int i=0;i<n;i++)cin>>s[i];
  vector<char>ret;
  for(int i=0;i<n;i++){
    int x = s[i][0]-'A';
    int y = s[i][1]-'A';
    if(a[x]==0&&a[y]==0)break;
    if(a[x]==0){
      a[x]++;
      a[y]--;
      ret.push_back(s[i][0]);
    } else if(a[y]==0){
      a[x]--;
      a[y]++;
      ret.push_back(s[i][1]);
    } else{
      if(a[x]==1&&a[y]>1){
        a[x]++;
        a[y]--;
        ret.push_back(s[i][0]);
      } else if(a[x]>1&&a[y]==1){
        a[y]++;
        a[x]--;
        ret.push_back(s[i][1]);
      } else {
        int tt = 3 - x - y;
        if(a[tt]>0||i==n-1){
          a[x]--;
          a[y]++;
          ret.push_back(s[i][1]);
        } else {
          int tt2 = s[i+1][0] - 'A';
          int tt3 = s[i+1][1] - 'A';
          if(x==tt2||x==tt3){
            a[x]++;
            a[y]--;
            ret.push_back(s[i][0]);
          } else {
            a[x]--;
            a[y]++;
            ret.push_back(s[i][1]);
          }
        }
      }
    }
  }
  if(ret.size()==n){
    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++)cout<<ret[i]<<endl;
  }else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 6884
N = int(input().strip())
B = list(map(int, input().strip().split(" ")))

S = B[0]
pre_b = -1

for i in range(len(B)):
  val = max(pre_b, B[i])
  if i < N - 2:
    if B[i] > B[i + 1]:
      val = B[i + 1]

  S += val
  pre_b = val
  
print(S)

Measured memory_bytes: 3060
import math
mod = 10**9+7
n = int(input())
ans = 1
a = 2
b = 1
for i in range(0 , n):
	ans  = (ans%mod)*(10%mod)
	ans = ans%mod
	a = (a%mod)*(9%mod)
	b = (b%mod)*(8%mod)
	a =a%mod
	b =b%mod
          
ans = (ans%mod - (a-b)%mod)%mod
print(ans)

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

int main()
{
    int n, w;
    cin >> n >> w;
    int v[n], wt[n];
    for (int i = 0; i < n; i++)
    {
        cin >> wt[i];
        cin >> v[i];
    }
    vector<long long> dp(w + 1, 0);
    for (int i = 0; i < n; i++)
    {
        for (long long j = w - wt[i]; j >= 0; j--)
        {

            dp[j + wt[i]] = max(dp[j + wt[i]], v[i] + dp[j]);
        }
        // for (int i = 0; i < w + 1; i++)
        // {
        //     cout << dp[i] << " ";
        // }
        // cout << endl;
    }
    long long ans = 0;
    for (int i = 0; i < w + 1; i++)
    {
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
#include<stdio.h>
long long max(long long a,long long b,long long c,long long d){
  if(a>b){
    if(a>c){
      if(a>d){
        return a;
      }
      else{
        return d;
      }
    }
    else{
      if(c>d){
        return c;
      }
      else{
        return d;
      }
    }
  }
  else{
    if(b>c){
      if(b>d){
        return b;
      }
      else{
        return d;
      }
    }
    else{
      if(c>d){
        return c;
      }
      else{
        return d;
      }
    }
  }
}

int main(){
  long long a,b,c,d;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  
  printf("%lld",max(a*c,a*d,b*c,b*d));
  return 0;
  
  
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 998244353LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);  

    int t; cin >> t; cout << 3*t*t << endl;
}

Measured memory_bytes: 1020
import java.util.*;

public class Main {
    
  public static void main(String[] args) {
   
      Scanner sc = new Scanner(System.in);                      
               
      int N = sc.nextInt();
     
      int max = Integer.MIN_VALUE;
      
      int a[] = new int[N];
      
      for(int i = 1 ;i <= N;i++){
          int c = sc.nextInt();
          a[i-1] = c;
          if(c > max){
              max = c;
          }
      }
      
      int count[] = new int[max+2];
            
      for(int i = 0;i < N;i++){
          if(a[i] == 0){
              count[a[i]]++;
              count[a[i]+1]++;
          }else{
              count[a[i]-1]++;
              count[a[i]]++;
              count[a[i]+1]++;
          }
      }      
      
      int ans = Integer.MIN_VALUE;
      
      for(int i = 0;i < max+2;i++){
          if(count[i] > ans){
              ans = count[i];
          }          
      }
      
      System.out.println(ans);
     
      
  }                
}
    




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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



int main() {
    ll n,k; cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end(), greater<ll>());
    ll ans = 0;
    rep(i, n) {
        if(k > 0) {
            k--;
            continue;
        } else {
            ans += h[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
        int n;cin>>n;
        int k;cin>>k;
        char s;
        string ss;
        for(int i=0;i<n;i++){
                cin>>s;
                if(i==k-1){
                        s+=0x20;
                }
                ss+=s;
        }
        cout<<ss<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>


typedef long long ll;
int main()
{
	int n;
	std::cin >> n;
	std::vector<std::string> s(n);

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

	for (int i = 0; i < s.size();i++) {
		for (int j = 0; j < s.size(); j++) {
			if (i != j && s[i] == s[j]) {
				std::cout << "No";
				return 0;
			}
		}
	}

	auto tail = s[0].c_str()[s[0].length() -1];
	for (int i = 1; i < s.size(); i++) {
		auto head = s[i].c_str()[0];
		if (head != tail) {
			std::cout << "No";
			return 0;
		}
		tail = s[i].c_str()[s[i].length() - 1];
	}

	std::cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
const double pi = 3.1415926535898;

using namespace std;
int main()
{
	double a, b, h, m;
	cin>>a>>b>>h>>m;
	double theta = abs(0.5*(h*60+m) - m*6.0);
	double ans = sqrt(a*a + b*b - 2*a*b*cos(theta*pi/180));
	cout<<fixed<<setprecision(15)<<ans<<"\n";
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, int> _P;
const int INF = 1e9;
const ll MOD = 1000000007;
_P Ret_P(int y, int x, int num) { return _P(P(y, x), num); }
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  REP(i, H) { cin >> A[i]; }
  queue<_P> que;
  REP(i, H) REP(j, W) {
    if (A[i][j] == '#') {
      que.push(Ret_P(i, j, 0));
    }
  }
  ll ans = 0;
  while (!que.empty()) {
    _P p = que.front();
    que.pop();
    chmax<ll>(ans, p.second);
    int y = p.first.first, x = p.first.second, score = p.second;
    if (0 < x) {
      int ny = y, nx = x - 1;
      if (A[ny][nx] == '.') {
        A[ny][nx] = '#';
        que.push(Ret_P(ny, nx, score + 1));
      }
    }
    if (x < W - 1) {
      int ny = y, nx = x + 1;
      if (A[ny][nx] == '.') {
        A[ny][nx] = '#';
        que.push(Ret_P(ny, nx, score + 1));
      }
    }
    if (0 < y) {
      int ny = y - 1, nx = x;
      if (A[ny][nx] == '.') {
        A[ny][nx] = '#';
        que.push(Ret_P(ny, nx, score + 1));
      }
    }
    if (y < H - 1) {
      int ny = y + 1, nx = x;
      if (A[ny][nx] == '.') {
        A[ny][nx] = '#';
        que.push(Ret_P(ny, nx, score + 1));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 17160
/**
 *    author:  math2do
 *    created: 21.11.2019 15:43:6
**/

#include <bits/stdc++.h>

using namespace std;

const int pinf = (1U << 31) - 1;


vector <int> dp;

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

  int n;
  cin >> n;
  vector <int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  auto solve = [&](auto &Self, int idx) {
    if (idx == n - 1) return 0;
    if (dp[idx] != -1) return dp[idx];
    int cost = pinf;
    if (idx + 1 < n) {
      int ret = Self(Self, idx + 1);
      if (ret != pinf) {
        cost = min(cost, ret + abs(h[idx] - h[idx + 1]));
      }
    }

    if (idx + 2 < n) {
      int ret = Self(Self, idx + 2);
      if (ret != pinf) {
        cost = min(cost, ret + abs(h[idx] - h[idx + 2]));
      }
    }
    return dp[idx] = cost;
  };

  dp.resize(n + 2);
  fill(dp.begin(), dp.end(), -1);

  int ans = solve(solve, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#define itn int
#define reaD read
#define N 15
using namespace std;

long long num[N][N], p[N], n, ans;
string s; 

template < typename T > 
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	return x * w;
}

int main()
{
	cin>>s;
	n = s.size();
	for(int i = 0; i < n; i++)
		num[i + 1][i + 1] = s[i] - '0';
	for(int i = 0; i <= n; i++)
		p[i] = !i ? 1 : p[i - 1] * 2;
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
			num[i][j] = num[i][j - 1] * 10 + num[j][j];
	for(int i = 1; i <= n; i++)
		for(int j = i; j <= n; j++)
		{
			long long l = 1, r = 1;
			if(i - 2 >= 0)
				l = p[i - 2];
			if(n - j - 1 >= 0)
				r = p[n - j - 1];
			ans += num[i][j] * l * r; 
		}
	printf("%lld\n", ans); 
	return 0;
}

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

int main(void)
{
	string s;

	while(cin >> s)
	{
		for(int i=0; i<s.length(); i++)
			s[i] = (s[i]+23-'A')%26+'A';

		cout << s << endl;
	}
	return 0;
}

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

using namespace std;

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

string keywords[]  {"dream", "dreamer", "erase", "eraser"};

bool dfs(string &str)
{
    if(str.empty()){
        return true;
    }else{
        rep(i,4){
            if(keywords[i] == str.substr(0,keywords[i].length())){
                str = str.substr(keywords[i].length());
                if(dfs(str)) return true;
                str = keywords[i] + str;
            }
        }
    }
    return false;
}

int main() {
    string str;
    cin >> str;
    cout << (dfs(str) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 1704
N = gets.to_i
A, B = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)

problems = P.group_by { |score| 
  case score
  when 0..A
    0
  when (A + 1)..B
    1
  when (B + 1)..Float::INFINITY
    2
  end
}

puts [0, 1, 2].map { |i| (problems[i] || []).size }.min


Measured memory_bytes: 1788
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

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

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=INF;

int main()
{
	int x;
	cin>>x;
	cout<<(x^1);

	return 0;
}

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

int main() {
  int64_t x;
  cin >> x;
  int64_t a = x/500LL, b;
  x -= a*500LL;
  b = x/5LL;
  cout << 1000LL*a + 5LL*b << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, x, l;
    cin >> n;
    vector<pair<int, int>> spans(n);
    rep(i, n) {
        cin >> x >> l;
        spans[i].first = x + l;
        spans[i].second = x - l;
    }
    sort(spans.begin(), spans.end(), [](pair<int, int>& x, pair<int, int>& y) {
                return x.first < y.first;
            });
    int ans = 1;
    int t = spans[0].first;
    repf(i, 1, n) {
        if (t <= spans[i].second) {
            ans++;
            t = spans[i].first;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main ()
{
    int n;
    cin >> n;
    int m = n;
    int sum = 0;
    while (m) {
        sum += m%10;
        m /= 10;
    }
    if (n % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
// Devarshi

#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

int main(){

sync

int arr[3];
cin>>arr[0]>>arr[1]>>arr[2];

sort(arr,arr+3);
reverse(arr,arr+3);

int a=arr[0]*10+arr[1];
cout<<a+arr[2];

return 0;
}


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

int main(){
    int K,A,B;
    cin >> K >> A >> B;
    for(int i = A; i <= B; i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 81;
bool dp[N][N][2 * N * N];

int main() {
    int h, w;
    cin >> h >> w;
    VVI a(h, VI(w)), b(a);
    REP(i,h) REP(j,w) a[i][j] = in();
    REP(i,h) REP(j,w) b[i][j] = in();

    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    REP(i,h) REP(j,w) REP(d,2*N*N){
        if (!dp[i][j][d]) continue;
        if (i < h - 1){
            int x = abs(a[i + 1][j] - b[i + 1][j]);
            dp[i + 1][j][abs(d + x)] = true;
            dp[i + 1][j][abs(d - x)] = true;
        }
        if (j < w - 1){
            int x = abs(a[i][j + 1] - b[i][j + 1]);
            dp[i][j + 1][abs(d + x)] = true;
            dp[i][j + 1][abs(d - x)] = true;
        }
    }
    int ans = 1e9;
    REP(d,2*N*N) if (dp[h - 1][w - 1][d]) chmin(ans, d);
    cout << ans << endl;

    return 0;
}


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

int N, A[200000];

int solve(void) {
  auto maxp = A[1] - A[0];
  auto minr = min(A[0], A[1]);
  for (auto i = 2; i < N; i++) {
    maxp = max(maxp, A[i] - minr);
    minr = min(minr, A[i]);
  }
  return maxp;
}

int main(void){
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  cout << solve() << endl;
  
  return 0;
}

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

int main(){
  int num;
  cin >> num;
  int cnt = 100000000000000000000;
  int now_num;
  for(int i = 0; i < num; i++){
    cin >> now_num;
    int count = 0;
    while(true){
      if(now_num % 2 == 0){
        now_num /= 2;
        count += 1;
      }
      else{
        break;
      }
    }
    if(count < cnt){
      cnt = count;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3612
//#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
#include <cmath>

using namespace std;

long gcd(long a, long b){
	long A, B, R;

	if (a > b){
		A = a;
		B = b;
	}
	else{
		A = b;
		B = a;
	}

	while (1){
		R = A % B;
		if (R == 0){
			return B;
		}
		else{
			A = B;
			B = R;
		}
	}
}

long lcm(long a, long b){
	long A, B;

	A = a;
	B = b;

	while (1){
		if (A > B){
			B = ceil((float)A / (float)b) * b;
		}
		else{
			A = ceil((float)B / (float)a) * a;
		}

		if (A == B) return A;
	}

}


int main(){

	int n;
	long a, b;
	long gcd_a, lcm_a;


	while (cin >> a >> b){

		gcd_a = gcd(a, b);
		lcm_a = lcm(a, b);

		cout << gcd_a << " " << lcm_a << endl;
	}

	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;	
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int cnt;
string s;

signed main() {
	fastio;
	cin >> s;
	FOR(i, sz(s)) {
		cnt += atoi(s[i]);
		cnt %= 9;
	}
	cout << (cnt ? "No" : "Yes");
}

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

using namespace std;

template <class T> bool uax(T& a, T b) {return a < b ? (a = b, true) : false; }
template <class T> bool uin(T& a, T b) {return a > b ? (a = b, true) : false; }

const int mod = (int) 1e9 + 7;
const int MANY = 1 << 30;
const int N = (int) 1e5 + 10;

int a[N][3], n, m;

int d[N][3];

int32_t main() {
//#ifndef QQQ
//    freopen("input.in", "r", stdin);
//    freopen("output.out", "w", stdout);
//#endif
#ifdef QQQ
    freopen("../input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    fill(&d[1][0], &d[n][3], -MANY);
    for (int j = 1; j <= n; ++j) {
        for (int i = 0; i < 3; ++i) {
            for (int k = 0; k < 3; ++k) {
                if (i != k) uax(d[j][i], d[j - 1][k] + a[j][i]);
            }
        }
    }
    int ans = -MANY;
    for (int i = 0; i < 3; ++i) {
        uax(ans, d[n][i]);
    }

    cout << ans;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		int part = 0;
		int P = 0;
		int E = 0;

		while (P < N) {
			if (P == N-1) {
				part++;
				break;
			}

			E = P + 1;

			while(E < N && A[E-1] == A[E]) {
				E++;
			}

			if (A[P] <= A[E]) {
				while(E < N && A[E-1] <= A[E]) {
					E++;
				}
				part++;
			} else {
				while(E < N && A[E-1] >= A[E]) {
					E++;
				}
				part++;
			}
			P = E;
		}
		System.out.println(part);
	}
}


Measured memory_bytes: 49348
n = gets.to_i

streak = 0

n.times do
  d1, d2 = gets.split.map(&:to_i)
  if d1 == d2
    streak += 1
    if streak >= 3
      puts 'Yes'
      exit 0
    end
  else
    streak = 0
  end
end

puts 'No'


Measured memory_bytes: 14380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class Main{
    public static void main(String[] a) throws IOException{
        BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringBuffer str1 = new StringBuffer("");
		if(str != null && !str.isEmpty()) {
			int l =str.length();
			for(int i=l-1;i>=0;i--) {
				str1.append(str.charAt(i));
			}
			System.out.println(str1);
		}
    }
}

Measured memory_bytes: 23952