akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype>         //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　 //浮点数处理
#include <ciso646>         //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal>         //信号机制支持
#include <csetjmp>         //异常处理支持
#include <cstdarg>         //不定参数列表支持
#include <cstddef>         //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　 //文件输入／输出
#include <functional>　　　//STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale>         //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory>         //STL通过分配器进行的内存分配
#include<new>            //动态内存分配
#include <numeric>         //STL常用的数字操作
#include <iomanip> 　　　 //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator>        //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo>        //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray>        //对包含值的数组的操作
#include <vector>　　　　　//STL 动态数组容器
using namespace std;
#define ll long long 
int main () {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll f = min(k, x / d);
  k -= f;
  x -= f * d;
  
  if(k & 1) cout << d - x << endl;
  else cout << x << endl;
}


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

int main() {
    int L;
    cin >> L;
    double l = (double) L/3;
    double S = pow(l,3);
    cout << fixed << setprecision(8) << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,ans=0;
	cin>>a>>b>>c;
	if(a==b){
		ans++;
	}
	if(a==c){
		ans++;
	}
	if(b==c){
		ans++;
	}
	if(ans==1)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 256
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif

    ll n , r;
    cin >>n >> r;
    if(n>=10) {
    	cout << r ;
    }
    else {
    	cout << (100)*(10 - n) + r;
    }

    return 0;
}

Measured memory_bytes: 256
import numpy as np

A = np.array([list(map(int, input().split())) for _ in range(3)])
N = int(input())
for _ in range(N):
    b = int(input())
    A[np.where(A == b)] = -1

if -3 in np.sum(A, axis=1) or -3 in np.sum(A, axis=0):
    print("Yes")
elif A[0, 0] + A[1, 1] + A[2, 2] == -3:
    print("Yes")
elif A[0, 2] + A[1, 1] + A[2, 0] == -3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12448
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	ll a, b, x;
	cin >> a >> b >> x;
	cout << (a == 0 ? b / x + 1 : b / x - (a - 1) / x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vl A(N);
  ll sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  sort(ALL(A), REV(ll));
  // cout << A[M - 1] << endl;
  if (A[M - 1] * 4 * M >= sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//0152
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = Integer.parseInt(sc.nextLine());
            if (n == 0)
                break;
            int[][] sl = new int[n][2];
            for (int i = 0; i < n; i++) {
                String[] l = sc.nextLine().split(" ");
                int[] s = new int[l.length];
                for (int j = 0; j < l.length; j++) {
                    s[j] = Integer.parseInt(l[j]);
                }
                int t = 0;
                for (int j = 0, p = 1; j < 10; j++) {
                    if (s[p] == 10) {
                        t += 10 + s[p + 1] + s[p + 2];
                        p++;
                    } else if (s[p] + s[p + 1] == 10) {
                        t += 10 + s[p + 2];
                        p += 2;
                    } else {
                        t += s[p] + s[p + 1];
                        p += 2;
                    }
                }
                sl[i][0] = s[0];
                sl[i][1] = t;
            }
            for (int i = 0; i < n - 1; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (sl[i][1] < sl[j][1]) {
                        int t = sl[i][0];
                        sl[i][0] = sl[j][0];
                        sl[j][0] = t;
                        t = sl[i][1];
                        sl[i][1] = sl[j][1];
                        sl[j][1] = t;
                    } else if (sl[i][0] > sl[j][0] && sl[i][1] == sl[j][1]) {
                        int t = sl[i][0];
                        sl[i][0] = sl[j][0];
                        sl[j][0] = t;
                    }
                }
            }
            for (int[] i : sl) {
                System.out.println(i[0] + " " + i[1]);
            }
        }
    }
}


Measured memory_bytes: 29236
#coding=UTF-8

N=int(input())

mozir=input()
hyo=mozir.split(' ')
a=[int(mono) for mono in hyo]

mobius=0
huckel=0
ungerade=0
for mono in a:
    if mono % 2 == 0:
        if mono % 4 == 0:
            mobius+=1
        else:
            huckel+=1
    else:
        ungerade+=1

#place 1,3,5,7, ...
#if ceil((N-1)/2) <= mobius then OK
if mobius >= N // 2:
    ans=True
else:
    #use huckel N-1,N-2,...
    #til colides to mobius
    hashi=mobius*2-1

    rightend=N-huckel
    if rightend-hashi<=1:
        ans=True
    else:
        ans=False

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15192
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#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 std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 200200;
int n,d,b;
int t[4*MAXN],a[MAXN];

void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(v*2, tl, tm);
        build(v*2+1, tm+1, tr);
        t[v] = 0;
    }
}

void update(int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && r == tr) {
        t[v] += add;
    } else {
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), add);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, add);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return t[v] + get(v*2, tl, tm, pos);
    else
        return t[v] + get(v*2+1, tm+1, tr, pos);
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> n >> d >> b;
  vpi v(n);
  vi vec;
  for(int i=0;i<n;i++){
    cin >> v[i].fs >> v[i].sc;
    vec.pb(v[i].fs);
  }
  sort(all(v));
  sort(all(vec));
  build(1,0,n-1);
  int ans = 0;
  for(int i=0;i<n;i++){
    int cur = get(1,0,n-1,i);
    int req = (v[i].sc+b-1)/b;
    if(cur>=req){
      continue;
    }
    else {
      int need = req-cur;
      int m = upper_bound(all(vec),v[i].fs+2*d) - vec.begin();
      m--;
      update(1,0,n-1,i,m,need);
      ans+=need;
    }
  }
  cout << ans << endl;



return 0;
}
///....


Measured memory_bytes: 10096
#include<stdio.h>
typedef struct{
  int strage[10];
  int sp;
} STACK;
void InitStack(STACK *s);
void push(STACK *s,int data);
int pop(STACK *s);
main(){
  int n;
  STACK s;
  InitStack(&s);
  while(scanf("%d",&n)!=EOF){
    if(n!=0)
      push(&s,n);
    else if(n==0)
      printf("%d\n",pop(&s));
  }
  return 0;
}

void InitStack(STACK *s){
  s->sp=0;
  return;
}

void push(STACK *s,int data){
  s->strage[s->sp]=data;
  s->sp++;
  return;
}

int pop(STACK *s){
  s->sp--;
  return(s->strage[s->sp]);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long

int f(int b,int n){
    int ret=0;
    int x=n;
    while(x>0){
        ret+=x%b;
        x/=b;
    }
    return ret;
}

signed main(){
    int n,s;cin >>n>>s;
    vector<int>v;
    int a=n-s;
    if(a<0){cout<<-1<<endl;return 0;}
    if(a==0){cout<<n+1<<endl;return 0;}
    
    for(int i=1;i*i<=a;i++){
        if(a%i!=0)continue;
        if(s==f(i+1,n)){
            cout<<i+1<<endl;
            return 0;
        }else{
            v.push_back(i);
        }
    }
    reverse(v.begin(),v.end());
    for(auto&& w:v)if(s==f((a/w)+1,n)){
        cout<<(a/w)+1<<endl;
        return 0;
    }    
    cout<< -1<<endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = 0
    for i in range(1, n+1):
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i%3 == 0:
            pass
        elif i%5 == 0:
            pass 
        else:
            s += i
    print(s)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  std::string ABCD;
  std::cin >> ABCD;
  for (int bit = 0; bit < (1 << 3); ++bit)
  {
    int t = ABCD[0] - '0';
    for (int i = 0; i < 3; ++i)
    {
      if (bit & (1 << i))
        t += ABCD[i + 1] - '0';
      else
        t -= ABCD[i + 1] - '0';
    }
    if (t == 7)
    {
      cout << ABCD[0];
      for (int i = 0; i < 3; ++i)
      {
        if (bit & (1 << i))
          cout << '+';
        else
          cout << '-';
        cout << ABCD[i + 1];
      }
      cout << "=7" << endl;
      break;
    }
  }

  return 0;
}


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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int cnt[55];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    for(int i = 1; i <= n; i++)cout << cnt[i] << '\n';
    return 0;
}
// Write Here


Measured memory_bytes: 3616
from collections import defaultdict
from collections import deque

graph = defaultdict(list)

V, E = map(int, input().split())
for _ in range(E):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

ans = defaultdict(lambda: -1)
que = deque([1])
ans[1] = 1
while len(que) > 0:
    u = que.popleft()
    for v in graph[u]:
        if ans[v] == -1:
            ans[v] = u
            que.append(v)

if len(ans) != V:
    print('No')
else:
    print('Yes')
    for v in range(2, V + 1):
        print(ans[v])

Measured memory_bytes: 47564
#include<stdio.h>
#include<string.h>
int main()
{
	char s[5];
	scanf("%s",s);
	int count=0;
	for(int i=0;i<4;i++)
	{
		if(s[i]==s[i+1])
			count++;
	}
	if(count>0)
		printf("Bad");
	else
		printf("Good");
	return 0;
}



Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    kitai=[0]*N
    for i in range(N):
        kitai[i]=(p[i]+1)/2

    ss=sum(kitai[0:K])
    ssmax=ss
    for i in range(N-K):
        ss-=kitai[i]
        ss+=kitai[i+K]
        if ssmax<ss:
            ssmax=ss

    print(ssmax)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32532
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x;
  cin>>x;
  int a,b,c;
  a=0;b=0;c=0;
  for(int i=0;i<3;i++){
    if(x[i]=='a'){
      a+=1;
    }else if(x[i]=='b'){
      b+=1;
    }else if(x[i]=='c'){
      c+=1;
    }
  }
  if(a==1&&b==1&&c==1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int age, A, B;

	cin >> age;

	if (age == 1) cout << "Hello World" << endl;
	else if (age == 2) {
		cin >> A;
		cin >> B;
		cout << A + B << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef double dd;
const int MOD = 1e9 + 7;

void solve(){ 
  ll n, x, m;
  cin >> n >> x >> m;
  map<ll, ll>vis;
  queue<ll>q;
  ll cx = x, loop = 0, sum = 0;
  vis[x] = 1;
  for(ll i = 1; i <= m; i++) {
    q.push(x);
    sum += x;
    x = x * x % m;
    if(vis[x] != 0) {
      loop = x;
      break;
    }
    vis[x] = 1;
    if(x == 0) {
      cout << sum << endl;
      return;
    }
  }
  ll lsum = 0, lpos = 0;
  while(q.front() != loop) {
    lsum += q.front();
    q.pop();
    lpos++;
  }
  ll ans = lsum, qsize = (ll) q.size();
  n -= lpos;
  sum -= lsum;
  ans += sum * (n/qsize);
  n %= qsize;
  ll i = 0;
  while(n--) {
    ans += q.front();
    q.pop();
  }
  cout << ans << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1, tt = 0;
  //cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << t << ": ";
    solve();
  }
  return 0;
}


Measured memory_bytes: 7140
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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

const ll mod = 998244353;

#define MAX_N 410000
int dat[2 * MAX_N - 1];


template<typename T>
class SegTree{
public:
    //セグメント木を持つグローバル変数
    int n;

    void init(int n_, T init_num){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2*n-1; i++){
            dat[i] = init_num;
        }
    }

    // k番目の値(0-indexed)をaに変更
    void update(int k, T a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = max(dat[k*2+1], dat[k*2+2]);
        }
    }

    // [a, b)の最小値を求める。
    // kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
    // query(a, b, 0, 0, n)で外からは呼び出す。
private: T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return 0;
        }

        if (a <= l && r <= b) {
            return dat[k];
        } else {
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
    // [a, b)の最小値を求める。
public: T query(int a, int b){
        return query(a, b, 0, 0, this->n);
    }
};


inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}


vector<ll> dp(210000, 0);
vector<int> next1(210000, -1);
vector<int> next2(210000, -1);


int main(){
    int n;
    cin >> n;
    vector<P> x2;
    for(int i = 0; i < n; i++){
        ll xx, dd;  cin >> xx >> dd;
        x2.emplace_back(P(xx, dd));
    }
    sort(x2.begin(), x2.end());

    vector<ll> x(n, 0), d(n, 0);
    for(int i = 0; i < n; i++){
        x[i] = x2[i].fs;
        d[i] = x2[i].sc;
    }

    SegTree<int> st;
    st.init(n, -1);
    for(int i = 0; i < n; i++){
        st.update(i, i+1);
    }

    for(int i = n-1; i >= 0; i--){
        int next_ind = lower_bound(x.begin(), x.end(), x[i] + d[i]) - x.begin();
        if(i+1 == next_ind){
            next1[i] = i+1;
        }
        else {
            next1[i] = st.query(i + 1, next_ind);
        }
        st.update(i, next1[i]);
    }

    dp[0] = 1;

    for(int i = 0; i < n; i++){
        // 選ぶ場合
        int nex = st.query(i, i+1);
        dp[nex] = add(dp[nex], dp[i]);
        // 選ばない場合
        dp[i+1] = add(dp[i+1], dp[i]);
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 12652
#include<iostream>
#include <cmath>
#include<cstdio>
#include <string>
#include <cwchar>
#include <stdio.h>
#include <ctype.h>
using namespace std;
int gcd(int a,int b)
{
	if(a==0)
	return b;
	
	 return gcd(b%a,a);
}
int main(){
	long long int n;
	cin>>n;
	long long int sum=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				sum+=gcd(k,gcd(i,j));
			}
		}
	
	}
	cout<<sum<<endl;
}


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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int min_ls_sub_rs = 0;
    int ls_sub_rs = 0;
    for (char c : s) {
        if (c == '(')  ls_sub_rs++; else ls_sub_rs--;
        min_ls_sub_rs = min(min_ls_sub_rs, ls_sub_rs);
    }
    cout << string(-min_ls_sub_rs, '(') << s
         << string(ls_sub_rs - min_ls_sub_rs, ')') << '\n';
}


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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		long n = Integer.parseInt(tmpArray[0]);
		long m = Integer.parseInt(tmpArray[1]);
		
		if(n > m){
			long tmp = n;
			n = m;
			m = tmp;
			
		}
		
		if(n == 1){
			if(m == 1){
				System.out.println(1);
			}
			else {
				System.out.println(m - 2);
			}
			return;
		}
		System.out.println((m - 2)*(n - 2));

	}

}


Measured memory_bytes: 22996
// ------------------------------------
// Date:2018/ 4/ 2
// Problem:D - Wall d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 2e2 + 1;

int H, W;
int c[10][10];

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

  cin >> H >> W;
  REP(hi, 10)
    REP(wi, 10)
      cin >> c[hi][wi];

  REP(k, 10) {
    REP(i, 10) {
      REP(j, 10) {
	c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }

  ll ans = 0ll;
  REP(hi, H) { 
    REP(wi, W) {
      CIN(a);
      if (a < 0) continue;
      ans += c[a][1];
    }
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
"use strict";
function main(input) {
  const n = parseInt(input[0]);
  let p = parseInt(input[1].trim().split(" ").join(""));
  let q = parseInt(input[2].trim().split(" ").join(""));

  const permutation = (nums, k) => {
    let ans = []
    if (nums.length < k) {
      return []
    }
    if (k===1) {
      for (let i=0;i<nums.length;i++) {
          ans[i] = [nums[i]];
      }
    } else {
      for (let i=0;i<nums.length;i++) {
        let parts = nums.slice(0);
        parts.splice(i, 1)[0];
        let row = permutation(parts, k - 1);
        for (let j=0;j<row.length;j++) {
          ans.push([nums[i]].concat(row[j]));
        }
      }
    }
    return ans;
  }

  let str = [];

  for(let i=1;i<=n;i++){
    str.push((i+""));
  }

  let all = permutation(str, n);
  let counter = 0;

  if(p!==q){
    for(let i=0;i<all.length;i++){
      let s = parseInt(all[i].join(""));
      if(((s>p) && (s<q)) || ((s<p) && (s>q))){
        counter++;
      }
    }
    console.log(counter+1);
  }else{
    console.log(0);
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 30804
import Data.Bool
import qualified Data.ByteString.Char8 as BS

main :: IO()
main = do
  (a, b, c) <- BS.foldl' step (0, 0, 0) <$> BS.getLine
  putStrLn . bool "NO" "YES" $ all ((<2) . abs) [a - b, b - c, c - a]
  where
    step (x, y, z) c
      | c == 'a' = (x + 1, y, z)
      | c == 'b' = (x, y + 1, z)
      | c == 'c' = (x, y, z + 1)


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

using namespace std;

typedef long long ll;

ll mod = 998244353;
int c[30];
int v[21];

int main(int, char**)
{
	ll n, ans2 = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}

	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		v[i] = c[i] - x;
		if (v[i] > 0) ans2 += v[i];
	}

	cout << ans2 << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int H,W,h,w;
	scanf("%d%d%d%d",&H,&W,&h,&w);
	
	if(H%h == 0 && W%w == 0){
		puts("No");
		return 0;
	}
	
	puts("Yes");
	rep(i,H)rep(j,W){
		int a = 0;
		if(i%h == 0 && j%w == 0)a = 999999999;
		if(i%h == h-1 && j%w == w-1)a = -1000000000;
		printf("%d%c",a,(j == W-1)?'\n':' ');
	}
}



Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n, i, cnt=0;
    cin >> n;
    int array[n];
    for(i=1;i<=n;++i) {
        cin >> array[i];
        if((i%2) && (array[i]%2)) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    int a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    bool flag = false;
    if (a==b) {
        flag = true;
    }else if(v>w){
        if(abs(b-a)*1.0/(v-w)<=t){
            flag = true;
        }
    }
    YES(flag);
}


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

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

	map<char, char>map_st, map_ts;

	bool can = true;

	for (int i = 0; i < s.size(); i++) {

		char tmp_s = s[i];
		char tmp_t = t[i];

		if (map_st.count(tmp_s)) {
			if (map_st[tmp_s] != tmp_t) can = false;
		}
		if (map_ts.count(tmp_t)) {
			if (map_ts[tmp_t] != tmp_s) can = false;
		}
		map_st[tmp_s] = tmp_t;
		map_ts[tmp_t] =tmp_s;

	}

	string ans = "No";
	if (can) ans = "Yes";

	cout << ans << endl;

	return 0;
}

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

#define ll long long int

int main()
{
    int c[3][3];
    int a[3], b[3];

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= 100; j++)
        {
            for (int k = 0; k <= 100; k++)
            {
                a[0] = i;
                a[1] = j;
                a[2] = k;
                bool f = true;
                for (int l = 0; l < 3; l++)
                {
                    for (int m = 0; m < 3; m++)
                    {
                        if (l == 0)
                        {
                            b[m] = c[l][m] - a[l];
                        }
                        else
                        {
                            if (a[l] + b[m] != c[l][m])
                            {
                                f = false;
                                break;
                            }
                        }
                        /*if (a[0] == 0 && a[1] == 1 && a[2] == 0)
                        {
                            for (int l = 0; l < 3; l++)
                            {
                                cout << a[l] << " ";
                            }
                            for (int l = 0; l < 3; l++)
                            {
                                cout << b[l] << " ";
                            }
                            cout << endl;
                        }*/
                    }
                }
                if (f)
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x=0,a;
    cin>>n;
    long long ans=0;
    int m=INT_MAX;
    while(n--)
    {
        cin>>a;
        ans+=abs(a);
        m=min(m,abs(a));
        if(a<0)
        x++;
    }
    if(x&1)
    ans-=2*m;
    cout << ans ;
    return 0;
}


Measured memory_bytes: 256
type ABC(stream:System.IO.TextReader) =
  member this.Scan4 f1 f2 f3 f4 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2], f4 a.[3]))

let util = ABC(stdin)
let W,H,x,y = util.Scan4 float float float float
let area = W * H / 2.0
match W=2.0*x, H=2.0*y with
| true, true -> "1"
| _ -> "0"
|> printfn "%.10f %s" area

Measured memory_bytes: 14044
#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(){
    int a,b; cin >> a >> b;
    if(a <= b) cout << a << endl;
    else cout << a-1 << endl;
}

Measured memory_bytes: 256
s = list(input())

count = 0
for i in range(len(s)-1):
  if s[i] == s[i+1] and s[i] == "0":
    s[i+1] = "1"
    count += 1
  elif s[i] == s[i+1] and s[i] == "1":
    s[i+1] = "0"
    count += 1
  else:
    pass
  
print(count)

Measured memory_bytes: 9856
#include <stdio.h>
int i,j=0;
double y=0,x[10],vx,vy;
int main(){
while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&x[1],&x[2],&x[3],&x[4],&x[5],&x[6],&x[7],&x[8],&x[9],&vx,&vy) != EOF){
j=0; y=0;
	for(i=0;i<10;i++){
y += x[i];
}
double vz=vx+vy; y *= vx/vz;
while(1){
y-=x[j];
if(y<=0) {printf("%d\n",j+1); break;}
j++;
}
}
return 0;
}


  

Measured memory_bytes: 624
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    long[] a = new long[N];
    long[] sum = new long[N + 1];
    long ans = 10000000000000L;
    for (int i = 0; i < N; i++){
      a[i] = scanner.nextLong();
    }
    sum[0] = a[0];
    for (int i = 1; i < N; i++){
      sum[i] = sum[i - 1] + a[i];
    }
    for (int i = 0; i < N - 1; i++){
      ans = Math.min(ans, Math.abs(sum[N - 1] - 2 * sum[i]));
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 88060
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
    int h,a;
    cin >> h >> a;
    int ans = h/a;
    if(h%a != 0) ans++;
    cout << ans << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, A;
	cin >> N >> A;

	cout << N*N - A << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

li mod = 0;

li pow(li x, li n) {
    if (n == 0) {
        return 1;
    }
    if (n == 1) {
        return x;
    }

    li sq = pow(x, n / 2);
    if (n & 1) {
        return sq * sq % mod * x % mod;
    }
    return sq * sq % mod;
}

li inv(li x) {
    return pow(x, mod - 2);
}

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

    li p;
    cin >> p;
    mod = p;

    vector<li> xs(p);
    for (int i = 0; i < p; ++i) {
        cin >> xs[i];
    }

    vector<li> ys(p);
    for (int i = 0; i < p; ++i) {
        vector<li> poly(p + 1);
        poly[p] = 1;
        poly[1] = (p - 1);

        vector<li> div(p + 1);

        for (int d = p; d >= 1; --d) {
            li c = (p - poly[d]) % p * i % p;
            div[d - 1] = poly[d];
            poly[d] = 0;
            poly[d - 1] = (poly[d - 1] + p - c) % p;
        }

        for (int j = 0; j < p; ++j) {
            ys[j] = (ys[j] + div[j] * xs[i] % p * (p - 1) % p) % p;
        }
    }

    for (int i = 0; i < p; ++i) {
        cout << ys[i];
        if (i == p - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int H=0,W=0,i=0,j=0;
	for (i = 0; i < 300; ++i)
	{
		scanf("%d %d",&H,&W);
		if (H==0&&W==0)
		{
			break;
		}
		else
		{
			for (i = 0; i < H; ++i)
			{
				if(i%2==0)
				{
					for (j = 0; j < W; ++j)
					{
						if (j%2==0)
						{
							printf("#");
						}
						else
						{
							printf(".");
						}
					}
					printf("\n");
				}
				else
				{
					for (j = 0; j < W; ++j)
					{
						if (j%2==0)
						{
							printf(".");
						}			
						else
						{
							printf("#");
						}
					}
					printf("\n");
				}

			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
using namespace std;
int main(){
    int x,y; cin >> x >> y;
    bool flag=true;
    int crane=y-2*x;
    if(crane<0 || crane%2==1) flag=false;
    crane /=2;
    if(crane<0 or x<crane) flag=false;
    cout << (flag ? "Yes\n" : "No\n");
    return 0;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int n,k;cin>>n>>k;
  int ans=k;
  for(int i=2;i<=n;++i){
    ans*=k-1;
  }
  cout<<ans<<endl;

  return 0;
}



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

int main() {
	int r, c, table[101][101] = { 0 }, sum, all_sum = 0;
	cin >> r >> c;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> table[i][j];
			all_sum += table[i][j];
		}
	}
	for (int i = 0; i < r; i++) {
		sum = 0;
		for (int j = 0; j < c; j++) {
			sum += table[i][j];
		}
		table[i][c] += sum;
	}
	for (int j = 0; j < c; j++) {
		sum = 0;
		for (int i = 0; i < r; i++) {
			sum += table[i][j];
		}
		table[r][j] += sum;
	}
	table[r][c] = all_sum;
	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
			cout << table[i][j];
			if (j < c) cout << ' ';
		}
		cout << endl;
	}
}

Measured memory_bytes: 1208
S = input()
for i in range(2**3):
  formula = ""
  for j in range(3):
    formula += S[j]
    if (i>>j) & 1:
      formula += "+"
    else:
      formula += "-"
  formula += S[3]
  if eval(formula) == 7:
    print(formula + "=7")
    break

Measured memory_bytes: 61932
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {
    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();

        StringBuilder sb = new StringBuilder();
        for(int i = 0 ; i < ty - sy; i++) {
            sb.append("U");
        }
        for(int i = 0 ; i < tx - sx; i++) {
            sb.append("R");
        }
        for(int i = 0 ; i < ty - sy; i++) {
            sb.append("D");
        }
        for(int i = 0 ; i < tx - sx; i++) {
            sb.append("L");
        }

        sb.append("L");
        for(int i = 0 ; i < ty - sy + 1; i++) {
            sb.append("U");
        }
        for(int i = 0 ; i < tx - sx + 1; i++) {
            sb.append("R");
        }
        sb.append("D");

        sb.append("R");
        for(int i = 0 ; i < ty - sy + 1; i++) {
            sb.append("D");
        }
        for(int i = 0 ; i < tx - sx + 1; i++) {
            sb.append("L");
        }
        sb.append("U");

        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 9936
#include <iostream>
#include <vector>
#include <sstream>
#include <bitset>

std::string two (long long x ) {
  std::stringstream ss;
  ss << static_cast<std::bitset<22> >(x);
  std::string x_bin = ss.str();
  return x_bin;  
}

int main () {
  long long N;
  std::cin >> N;
  long long A[N];
  std::string x[N];
  std::string y[N];
  
  // 数字を2進数表示させる.
  for (long long i = 0; i < N; i++) {
    std::cin >> A[i];
    x[i] = two(A[i]);
    y[i] = two(A[i]);
  }

  // 2進数表示させた数字に対して, 足し算することができるか検証する.
  long long answer = N;
  bool forBool = false;
  bool forBoolfor = false;
\
  std::vector<int> iterator(22);
  for (int i = 0; i < 22; i++) {
    iterator[i] = 0;  
  }
  long long iterator_number = 1;

  // lをあえて0のみで考える.
  for (long long l = 0; l < N - 1; l++) {
    forBool = false;
    forBoolfor = false;
    iterator_number = (iterator_number > l) ? iterator_number: l + 1;

    if (l > 0 && iterator_number != (l + 1) ) {
      for (int q = 0; q < 22; q++) {
        if (x[l-1][q] == '2' && x[l][q] == '0') {
          // if (x[iterator_number][q] != '1') {}
          x[l][q] = '2';  
          // }
        }  
      }
    }

    for (long long r = iterator_number; r < N; r++) {

      for (int i = 0; i < 22; i++) {
        if (x[l][i] >= '1' && x[r][i] >= '1') {
          
          // l = 0 とrではxorにはならないという意味.
          forBool = true;
        }
        // std::cout << "x[2] " << x[2] << "x[4] " << x[1] << std::endl;
        if (forBool == true) {
          break;  
        }
        
        // 比較した位について1があったら1にする.
        if (x[l][i] == '0' && x[r][i] == '1') {
          x[l][i] = '3';  
        }
        
      }

      for (int i = 0; i < 22; i++) {
        if (forBool == true) {
          if (x[l][i] == '3'){
            x[l][i] = '0';  
          }  
        }
        else {
          if (x[l][i] == '3') {
            x[l][i] = '2';  
          }  
        }  
      }

      if (forBool == true) {

        answer = answer + (r - l - 1 );
        iterator_number = r;
        break;
      }
      
      if (r == N - 1 ) {
        answer = answer + (r + 1 - l) * (r - l ) / 2; 
        forBoolfor = true;
      }
      if (forBoolfor) {
        break;  
      }
    }  
    if (forBoolfor) {
      break;  
    }
  }

  std::cout << answer << std::endl;
}


Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const int N = 4;
    string s; cin >> s;
    REP(i,pow(2,N-1)) {
        int x = s[0] - '0';
        REP(j,N-1) {
            if ((i >> j) % 2 == 0) x += s[j+1] - '0';
            else x -= s[j+1] - '0';
        }
        if (x == 7) {
            cout << s[0];
            REP(j,N-1) {
                if ((i >> j) % 2 == 0) cout << "+" << s[j+1];
                else cout << "-" << s[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }

    return 0;
}

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

int main(void)
{
	float a, b;
	float av;
	int i;
	
	scanf("%f %f", &a, &b);
	
	av = a + b;
	av /= 2;
	
	i = (int)(av + 0.5);
	
	printf("%d\n", i);
	
	return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
const int mod=998244353;
const int maxn=1e5+5;
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int main()
{ 
  int s,w;
  cin>>s>>w;
  if(w>=s)cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
	return 0;
 } 

Measured memory_bytes: 3620