akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int r, g; cin >> r >> g;
    cout << g + (g - r) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int N, h[110], an = 0, H[110] = { 0 };
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &h[i]);
	}
	while (true) {
		int count = 0;
		for (int i = 0; i < N; i++) {
			if (H[i] == h[i]) {
				count++;
			}
			if (H[i] < h[i]) {
				H[i]++;
				if (H[i + 1] == h[i + 1]) {
					break;
				}
			}
		}
		if (count == N) {
			break;
		}
		an++;
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;
public class Main  {

	public static void main(String[] args) {
		Scanner scan =new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = (int)Math.pow(2, n)-1;
		
		int k = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		
		for(int i=0; i<k; i++) {
			list.add(scan.nextInt());
		}
		

		for(int i=0; i<=m; i++){
			String binary = Integer.toBinaryString(i);
			
			ArrayList<Integer> list2 = new ArrayList<>();
			for(int j=0; j<binary.length();  j++){
				if(binary.charAt(binary.length()-j-1) == '1') list2.add(j);
			}
			
			if(list2.size() >= list.size() && list2.containsAll(list)) {
			System.out.print(i + ":");
			for(int j=0; j<list2.size(); j++) System.out.print(" " + list2.get(j));
			System.out.println();
			}
		}
	}
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt N, K; cin >> N >> K;
	vlnt A(N);
	REP(i, N) {
		cin >> A[i];
		A[i]--;
	}
	vector<bool> visit(N, 0);
	lnt pos = 0;
	while(!visit[pos]){
		visit[pos] = 1;
		pos = A[pos];
		K--;
		if(K == 0){
			cout << pos+1 << ln;
			return 0;
		}
	}
	lnt start = pos;
	vlnt vec; lnt cnt = 0;
	do {
		vec.eb(pos);
		cnt++;
		pos = A[pos];
	} while(pos != start);
	K %= cnt;
	cout << vec[K]+1 << ln;
}

Measured memory_bytes: 5808
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int A, B;

int main()
{
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
}


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

char num[12];
int in;

int main () {

  while ( true ) {
    cin >> in;

    if ( in == 0 )
      break;

    for ( int i=0; i<len; i++ ) {
      num[i] = 0;
    }

    for ( int i=11; i>=0; i-- ) {
      
      num[i] = in%8+'0';
      in = in/8;
    }
  
    int count = 0;
    while ( num[count] == '0' )
      count++;
  

    for ( int i=count;i <len; i++ ) {
      if ( num[i] == '4' )
	cout << '5';
      else if ( num[i] >'4' )
	cout << (char)(num[i]+2);
      else
	cout << num[i];
    }
    cout << endl;
  }

}

Measured memory_bytes: 856
import java.util.Scanner;

public class Main {
    int n, m;
    private final int LONG = 1900;
    private final int SHORT = 100;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
    }

    private void solve() {
        double ans = 0.;
        double rat = 2 << (m - 1);
        double one = (LONG * m + SHORT * (n - m)) * (1. / rat);
        double co = (rat - 1.) / rat;
        double tmp = 0.;
        ans = one;
        int cnt = 1;
        while (ans - tmp > 0.01) {
            cnt++;
            tmp = ans;
            ans += (one * cnt) * co;
            co *= (rat - 1.) / rat;
        }
        System.out.println(Math.round(ans));
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n, k;   cin >> n >> k;
    int ans = 0;
    while(n >= k){
        ans++;
        n /= k;
    }
    cout << ++ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int A,B;
	scanf("%d%d",&A,&B);
	if(2<=A&&2<=B){
		if(A<B){
			printf("Bob");
		}else if(A>B){
			printf("Alice");
		}else{
			printf("Draw");
		}
	}else if(A==1&&2<B){
		printf("Alice");
	}else if(2<A&&B==1){
		printf("Bob");
	}else if(A==B){
		printf("Draw");
	}
	return 0;
}


Measured memory_bytes: 128
# https://abc096.contest.atcoder.jp/tasks/abc096_b

A, B, C = map(int, input().split())

K = int(input())

# print(K)

l = sorted([A, B, C])
m = l[-1]
rest = l[:-1:]

# print(m)
# print(rest)

total = m * 2 ** K + sum(rest)
print(total)


Measured memory_bytes: 2940
n, k=map(int, input().split())
box = []
a = n
b = n
while a>0:
    a, b = divmod(a,k)
    box.append(b)
#print(box)

l = len(box)
print(l)
#tot = ''
#for i in range(l):
#    tot = tot + str(box[l-1-i] * k**i)
#print(tot)
#print(len((tot)))
    
    
    

Measured memory_bytes: 2940
def resolve():
    n = int(input())
    d = sorted([int(i) for i in input().split()])
    half = int(len(d) / 2)
    abc = d[:half]
    arc = d[half:]

    if abc[-1] == arc[0]:
        print(0)
    else:
        print(arc[0] - abc[-1])

resolve()

Measured memory_bytes: 14392
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    cin >> n >> m;
    ll ans = 0;
    int a[m],b[m-1];
    for(int i = 0; i < m; i++){
        cin >> a[i];
    }
    sort(a,a+m);
    for(int i = 0; i < m-1; i++){
        b[i] = (a[i+1] - a[i]);
    }
    sort(b,b+m-1);
    for(int i = 0; i < m-n; i++){
        ans += b[i];
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
 
int main() {
    int n;cin>>n;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int k = 0;
    for(int i = 0;i<n-1;i++){
       k = gcd(a[i],a[i+1]);
       a[i+1] = k;
       //cout<<a[i]<<endl;
    }
    cout<<k;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

ll N, M;
ll A[100100];
ll S[100100];

bool solve(ll x){
    ll num = 0;
    REP(i,N){
        ll a = A[i];
        int idx = lower_bound(A, A+N, x-a) - A;
        num += (N - idx);
    }

    if(num < M)
        return false;
    else
        return true;
}

ll calc(ll x){
    ll num = 0;
    ll sum = 0;
    REP(i,N){
        ll a = A[i];
        int idx = lower_bound(A, A+N, x-a) - A;
        num += (N - idx);
        sum += S[idx] + a*(N-idx);
    }

    sum -= x*(num-M);

    return sum;
}

int main(){
    cin >> N >> M;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    sort(A, A+N);

    S[N] = 0;
    for(int i = N-1; i >= 0; i--){
        ll a = A[i];
        S[i] = a + S[i+1];
    }

    ll left = 0;
    ll right = 3*1e5;
    while(right - left > 1){
        ll mid = (left + right) / 2;
        bool valid = solve(mid);
        if(valid) left = mid;
        else right = mid;
    }

    //cout << left << endl;

    ll ans = calc(left);

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];

  ll ans = 0;
  ll tmp = 0;

  for(int i=N-1; i>0; --i) {
    tmp += A[i];
    ans += (A[i-1]%MOD)*(tmp%MOD);
    ans = ans%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

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

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;

	if (y == 1)
		return x % mod;

	return (pow_mod(x, y - 1, mod) * x) % mod;
}

int N;
int cnt;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin>>N;
	vector<ll> A(N);
	rep(i,0,N){
		int a;
		cin>>a;
		if(a<0){
			cnt++;
			a=-a;
		}
		A[i]=a;
	}
	sort(A.begin(),A.end());
	ll ans=0;
	rep(i,0,N)ans+=A[i];
	if(cnt%2)ans-=2*A[0];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int ans = 0;
    rep(i,100){
        ans = (i * 1000)-n;
        if(ans >= 0){
            cout<<ans<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3656
N=int(input())
S=[input() for i in range(N)]

data=[[] for i in range(N)]
for y in range(N):
    for x in range(N):
        if S[y][x]=="1":
            data[y].append(x)

visited=[-1 for i in range(N)]
visited[0]=0
stack=[[0,0]]

while stack:
    a,m=stack.pop()
    for p in data[a]:
        if visited[p]==m:
            print(-1)
            exit()
        else:
            if visited[p]==-1:
                n=(m+1)%2
                visited[p]=n
                stack.append([p,n])


d=[[10**18 for m in range(N)] for i in range(N)]

for x in range(len(d)):
    d[x][x]=0
for x in range(len(data)):
    for y in data[x]:
        d[x][y]=1
        d[y][x]=1
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j]=min(d[i][j],d[i][k] + d[k][j])
print(max([max([i for i in l]) for l in d])+1)


Measured memory_bytes: 43372
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
Q = int(input())
B, C = [], []
for i in range(Q):
	b, c = map(int, input().split())
	B.append(b)
	C.append(c)
	
dic = Counter(A)
ans = 0
for k, v in dic.items():
	ans += k*v
for i in range(Q):
	b, c = B[i], C[i]
	dic[c] += dic[b]
	ans += - b*dic[b] + c*dic[b]
	del dic[b]
	print(ans)


Measured memory_bytes: 104124
using System;
using System.Collections.Generic;
using System.Linq;

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

            if (n == 1)
            {
                Console.WriteLine("Hello World");
                return;
            }

            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());

            Console.WriteLine(a + b);
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(Math.min(a+b,Math.min(a+c,b+c)));
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}



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

int main() {
  int D, T, S;
  cin >> D >> T >> S;
  if(D <= T * S){
  	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
	public static void main(String[] args){

        Scanner s = new Scanner(System.in);
		int b=0,f=0,r=0,v=0,i,j,k;				//b棟f階のr番目の部屋にv人
		int[][][] heya = new int[4][3][10];
        int n = s.nextInt();
        
		for(i=0;i<n;i++){
				b=s.nextInt();
          	    f=s.nextInt();
				r=s.nextInt();
         	    v=s.nextInt();
            	
            	if(b<5&&b>=1&&f<4&&f>=1&&r<11&&r>=1&&(heya[b-1][f-1][r-1]+v)>=0&&(heya[b-1][f-1][r-1]+v)<10)heya[b-1][f-1][r-1]+=v;
            
        }
        for(i=0;i<4;i++){
              for(j=0;j<3;j++){
                  for(k=0;k<10;k++){
                      System.out.print(" "+heya[i][j][k]);
                      if(k==9)System.out.println();

                  }
              }
            if(i!=3)
            System.out.println("####################");
        }
         	   
            

		s.close();
	}
}


Measured memory_bytes: 30404
import math as m
A,B,H,M=map(int,input().split())
a=(30*H)+(M/2)
b=M*6
if b-a==180 or a-b==180:
    print(A+B)
else:
    if b-a>=0:
        if b-a<180:
            c=b-a
            d=m.radians(c)
            f=m.cos(d)
            e=A*A+B*B-2*A*B*f
            g=m.sqrt(e)
            print(g)
        else:
            c=360-(b-a)
            d=m.radians(c)
            f=m.cos(d)
            e=A*A+B*B-2*A*B*f
            g=m.sqrt(e)
            print(g)
    else:
        if a-b<180:
            c=a-b
            d=m.radians(c)
            f=m.cos(d)
            e=A*A+B*B-2*A*B*f
            g=m.sqrt(e)
            print(g)
        else:
            c=360-(a-b)
            d=m.radians(c)
            f=m.cos(d)
            e=A*A+B*B-2*A*B*f
            g=m.sqrt(e)
            print(g)

Measured memory_bytes: 9600
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let in1: i32 = read();
    let amari:i32 = in1 % 100;
    let syou:i32 = in1 /100;

    let amari5:i32 = in1 % 105;



    for x in 1..1001 {
        let syou0:i32 = 100* x;
        let syou5:i32 = 105* x;
        if (syou0<=in1 && in1<=syou5 ){
            println!("1");
            return;
        }
    }

    println!("0");
}

Measured memory_bytes: 4352
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val n = input.split(" ").head.toInt
    val y = input.split(" ").tail.head.toLong
//    (for (i <- 0 to n; j <- 0 to n-i) yield Vector(i, j, n - i - j)).toVector
//      .find(x => 10000L * x(0) + 5000L * x(1) + 1000L * x(2) == y)
//      .getOrElse(Vector(-1L, -1L, -1L))
//      .mkString(" ")

    (0 to n).flatMap{i =>
      (0 to n - i).map{j =>
        val k = n - i - j
        val ycand = 10000L * i + 5000L * j + 1000L * k
        if (ycand == y) (i, j, k) else (-1,-1,-1)
      }
    }.iterator.find(_._1 != -1).map(x => List(x._1, x._2, x._3)).getOrElse(List(-1, -1, -1)).mkString(" ")
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """9 45000""".stripMargin -> """4 0 5
                                   |""".stripMargin,
    """20 196000""".stripMargin -> """-1 -1 -1
                                     |""".stripMargin,
    """2000 20000000""".stripMargin -> """2000 0 0"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 115628
#include <iostream>
using namespace std;
void rotate(int& x,int& y){
  swap(x,y);
  x *= -1;
}
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x = c-a, y = d-b;
  rotate(x,y);
  cerr << x << ' ' << y << endl;
  c += x;
  d += y;
  cout << c << ' ' << d << ' ';
  rotate(x,y);
  c += x;
  d += y;
  cout << c << ' ' << d << endl;
  return 0;
}

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

using Color = bool;
constexpr Color WHITE = true;
constexpr Color BLACK = false;

void chmin(int& a, int b) {
    a = min(a, b);
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<Color>> color(H);
    vector<vector<int>> changeCount(H);
    for (int i : irange(0, H)) {
        color[i].resize(W);
        changeCount[i].resize(W, 999);
        for (int j : irange(0, W)) {
            char x;
            cin >> x;
            color[i][j] = (x == '.');
        }
    }
    changeCount[0][0] = (color[0][0] == WHITE) ? 0 : 1;
    for (int i : irange(0, H)) {
        for (int j : irange(0, W)) {
            if (i + 1 < H) {
                if (color[i][j] == color[i + 1][j]) {
                    chmin(changeCount[i + 1][j], changeCount[i][j]);
                } else {
                    chmin(changeCount[i + 1][j], changeCount[i][j] + 1);
                }
            }
            if (j + 1 < W) {
                if (color[i][j] == color[i][j + 1]) {
                    chmin(changeCount[i][j + 1], changeCount[i][j]);
                } else {
                    chmin(changeCount[i][j + 1], changeCount[i][j] + 1);
                }
            }
        }
    }
    int ans = changeCount[H - 1][W - 1];
    if (color[H - 1][W - 1] == BLACK) {
        ans += 1;
    }
    cout << (ans + 1) / 2 << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 1000000000
#define MAX_N 150005
using namespace std;

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x=i;
        if(i%3==0)cout<<" "<<i;
        else while(x){
            if(x%10==3){
                cout<<" "<<i;
                break;
            }
            x/=10;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 3100
a,b,c,d=map(int,input().split())
n=int(input())
one=min(4*a,2*b,1*c)
two=d
if 2*one<=two:
 print(n*one)
else:
 if n%2==0:
  print(n//2*two)
 else:
  print(n//2*two+one)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  int n;
  cin >> n;
  int sum = 0;
  vi x(n);
  rep(i, n) {
      cin >> x[i];
      sum += x[i];
  }
  int a = sum / n, ans0=0, b=a+1, ans1=0;
  rep(i, n)ans0 += (x[i] - a) * (x[i] - a);
  rep(i, n)ans1 += (x[i] - b) * (x[i] - b);

  cout << min(ans0, ans1) << endl;

  return 0;
}

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

const int MAX=1e5+5;
int T,CS[MAX],CT[MAX];
string s,t;

int main() {
	//freopen("input","r",stdin);
	cin>>s>>t>>T;
	for(int i=1;i<=s.size();i++)
		CS[i]=CS[i-1]+(s[i-1]=='B');
	for(int i=1;i<=t.size();i++)
		CT[i]=CT[i-1]+(t[i-1]=='B');
	int l1,r1,l2,r2;
	while(T--) {
		cin>>l1>>r1>>l2>>r2;
		int sumA=(r1-l1+1)+(CS[r1]-CS[l1-1]);
		int sumB=(r2-l2+1)+(CT[r2]-CT[l2-1]);
		cout<<(sumA%3==sumB%3?"YES":"NO")<<'\n';
	}
}


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

int main() {
	// your code goes here
	long long s,t;
	cin >> s;
	t=ceil(sqrt(s));
	if(t*t>s) t--;
	if(s==t*t){
		cout << "0 0 " << t << " 0 0 " << t << endl;
	} else {
		if((t+1)*(t+1)-s<=s-t*t){
			cout << "0 0 " << t+1 << " " << (t+1)*(t+1)-s << " 1 " << t+1 << endl;
		} else {
			cout << "1 0 " << t+1 << " " << s-t*t << " 0 " << t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int line = int.Parse(Console.ReadLine());
            List<string> list = new List<string>();
            for(int i=0; i<line; i++)
            {
                list.Add(Console.ReadLine());
            }

            IEnumerable<string> result = list.Distinct();
            Console.WriteLine(result.Count());
        }
    }
}

Measured memory_bytes: 48244
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;cin>>a>>b;
    if(a%2==1&&b%2==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

#define MOD 1000000007
#define pb push_back
#define LSB(x) ((x)&(-x))
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef set<double> setd;
typedef multiset<int> mseti;
typedef deque<int> dqi;
typedef deque<double> dqd;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef unordered_set<int> usi;
typedef unordered_set<ll> usl;

vi stones;
vi dp;
int n;

void solve() {
    dp[2] = abs(stones[2] - stones[1]);
    for(int i = 3; i <= n; i++) {
        dp[i] = min(dp[i-1]+abs(stones[i-1]-stones[i]), dp[i-2]+abs(stones[i-2]-stones[i]));
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    stones.resize(n+1);
    dp.resize(n+1, INT32_MAX-1e5);
    for(int i = 1; i <= n; i++) {
        cin >> stones[i];
    }
    dp[1] = 0;
    solve();
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int M_N = 200000;

vector<LL> fact;
vector<LL> inver(M_N+1);
 
LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=M_N;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[M_N]=fpow(fact[M_N],mod-2);
    for(int i=M_N-1;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}
 
LL hcombi(int n,int r){
    return combi(n+r-1,r); 
}
int main(){
    set_combi();
    int n,x;cin >> n >> x;
    vector<vector<LL>> dp(n+1,vector<LL> (512,0));
    dp[0][0] = 1;
    for (int k = 0; k <= x; k++) {
        for (int i = n-1; i >= 0; i--) {
            for (int j = 0; j < 512; j++) {
                dp[i+1][j^k] = (dp[i+1][j^k] + dp[i][j])%mod;
            }
        }
    }
    LL ans = 0;
    for (int i = 0; i <= n; i++) {
        if((n - i) % 2) continue;
        LL k = (n - i) / 2;
        ans = (ans + dp[i][x] * hcombi(x + 1, k))%mod;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 8096
#include<stdio.h>
 
#define MAX_SIZE 100
#define MIN_VALUE 0
#define MAX_VALUE 1000
#define IS_ERR(x) (x < MIN_VALUE || x > MAX_VALUE)
 
int main(void)
{
    int n, a, ar[MAX_SIZE];
    scanf("%d\n", &n);
 
    if(n > MAX_SIZE) return -1;
 
    for(int i=n-1;i >= 0;i--)
    {
        scanf("%d", &a);
 
        if(IS_ERR(a)) return -1;
 
        ar[i] = a;
    }
 
    for(int j=0;j < n;j++)
    {
        if(j != 0) printf(" ");
        printf("%d", ar[j]);
    }
 
    printf("\n");
 
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
#include <climits>
#include <numeric>

//usings
using namespace std;

//type def
typedef long long int64;
typedef pair<int, int> ii;

//consts
const int mod = 1e9 + 7;

//methods
template<typename T>
bool chmax(T& source, const T& compare_to) {
    if(source < compare_to) {
        source = compare_to;
        return true;
    }
    return false;
}

int modpow(int64 base, int n) {
    int64 ret = 1;
    while(n) {
        if(n & 1) ret = ret * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return ret;
}

class Solution {
private:
public:
    vector<int> solve(string& s, int n, int k, int cool) {
        vector<int> left(k), right(k); //lf[i] date idx of ith working day
        for(int i = 0, c = 0, day = 0; i < n && day < k; ++i) {
            if(c) {
                --c;
                continue;
            }
            if(s[i] == 'o') {
                left[day++] = i;
                c = cool;
            }
        }
        // cout << "show left: \n";
        // for(int i = 0; i < k; ++i) cout << left[i] << " ";
        // cout << endl;
        for(int i = n - 1, c = 0, day = k - 1; i >= 0 && day >= 0; --i) {
            if(c) {
                --c;
                continue;
            }
            if(s[i] == 'o') {
                right[day--] = i;
                c = cool;
            }
        }
        // cout << "show right: \n";
        // for(int i = 0; i < k; ++i) cout << right[i] << " ";
        // cout << endl;
        vector<int> ret;
        for(int i = 0; i < k; ++i) {
            if(left[i] == right[i]) {
                ret.push_back(left[i] + 1);
            }
        }
        return ret;
    }

    
};

int main() {
    int n, k ,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    Solution sol;
    auto ret = sol.solve(s, n, k, c);
    for(const auto& d : ret)
        cout << d << endl;
}

Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{ 
  int N;cin>>N;
  vector<vector<vector<vector<int> > > > DP (N+1,vector<vector<vector<int> > >(5,vector<vector<int> >(5,vector<int>(5,0))));
  DP[0][0][0][0] = 1;
  for (int n = 0; n < N; n++)
  {
    for (int i = 0; i < 5; i++)
    {
      for (int j = 0; j < 5; j++)
      {
        for (int k = 0; k < 5; k++)
        {
          for (int l = 1; l < 5; l++)
          {
            if(i == 1 && j == 2 && l == 3)continue;
            if(i == 1 && k == 2 && l == 3)continue;
            if(j == 1 && k == 2 && l == 3)continue;
            if(j == 2 && k == 1 && l == 3)continue;
            if(j == 1 && k == 3 && l == 2)continue;
            DP[n+1][j][k][l] += DP[n][i][j][k];
            DP[n+1][j][k][l] %= MOD;

          }
          
        }
        
        
      }
      
    }
    
  }
  int res = 0;
  for (int i = 1; i < 5; i++)
  {
    for (int j = 1; j < 5; j++)
    {
      for (int k = 1; k < 5; k++)
      {
        res += DP[N][i][j][k];
        res %= MOD;
      }
      
    }
    
  }
  cout<<res<<endl;
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if ((a + b) == (c + d)) cout << "Balanced" << endl;
  if ((a + b) < (c + d)) cout << "Right" << endl;
  if ((a + b) > (c + d)) cout << "Left" << endl;
 
 }

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <map>
using namespace std;
map<int,int> mp;
int x;
int main()
{
    mp[5]=0;
    mp[7]=0;
    for(int i=0;i<3;i++)
    {
        scanf("%d",&x);
        mp[x]++;
    }
    if(mp[5]==2&&mp[7]==1)
        printf("YES");
    else 
        printf("NO");
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
  char a, b, c;
  scanf("%c%c%c",&a,&b,&c);
  int x =  a+b+c;
  if(x == 65*3 || x == 66*3)
    printf("No");
  else
    printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const int inf=1<<29;
int n, m;
vector<int> to[1005];

vector<int> bfs(int sv){
    vector<int> dist(n, inf), pre(n, -1);
    queue<int> q;
    dist[sv]=0;
    q.push(sv);

    while(!q.empty()){
        int u=q.front(); q.pop();
        for(auto v:to[u]){
            if(dist[v]!=inf) continue;
            dist[v]=dist[u]+1;
            pre[v]=u;
            q.push(v);
        }
    }

    pair<int, int> best(inf, 0);
    rep(i,n){
        if(i==sv) continue;
        for(int j:to[i]){
            if(j==sv) chmin(best, make_pair(dist[i], i));
        }
    }
    if(best.first==inf) return vector<int>(n+1);
    vector<int> res;
    int v=best.second;
    while(v!=-1){
        res.push_back(v);
        v=pre[v];
    }
    return res;
}

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

    cin >> n >> m;
    rep(i,m){
        int a, b; cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
    }

    vector<int> ans(n+1);
    rep(i,n){
        auto now=bfs(i);
        if(now.size() < ans.size()) ans=now;
    }

    if(ans.size()==n+1){
        cout << -1 << endl;
        return 0;
    }

    cout << ans.size() << endl;
    for(int v:ans) cout << v+1 << endl;
    
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      	int cnt = 0;
      	int max = 0;
      	for(int i = 0; i < n; i++) {
        	int num = sc.nextInt();
          	if(num >= max) {
            	cnt++;
              	max = num;
            }
        }
      	System.out.println(cnt);
    }
}

Measured memory_bytes: 23380
import java.util.*;

public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int gd = gcd(A1,A2);
		for(int i=2;i<N;i++) {
			gd = gcd(gd, sc.nextInt()); 
		}
		System.out.println(gd);
		
	}
	
	public static int gcd(int a, int b) {
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		if(x%y==0) return y;
		else return gcd(y, x%y);
	}
}


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

int main(void) {
    int N;
    cin >> N;
    vector< int > A(N + 10);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    vector< long long > d(N + 10);
    for (int i = 1; i <= N; i++) {
        d[i] = 0L;
    }
    for (int i = 2; i <= N; i++) {
        if (i - A[i] >= 1) {
            ++d[i - A[i]];
        }
    }
    long long ans = 0L;
    for (int i = 1; i < N; i++) {
        if (A[i] + i <= N) {
            ans += d[A[i] + i];
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
int main (void){
    int loop1,loop2,loop3;
    int takasa,yoko;
    scanf("%d%d\n",&takasa,&yoko);
    char data[yoko+1];
    for(loop1=0;loop1<takasa;loop1++){
        for(loop2=0;loop2<yoko;loop2++){
            scanf("%c",&data[loop2]);
        }
        for(loop2=0;loop2<2;loop2++){
            for(loop3=0;loop3<yoko;loop3++){
                printf("%c",data[loop3]);
            }
            printf("\n");
        }
        scanf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N, K;
    cin >> N >> K;
    string s;
    cin >> s;
    s = s + "#";
    ll cnt = 0;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        if(s[i] != s[i + 1])cnt++;
        else ans++;
    }
    for(;K > 0 && cnt;K--){
        if(cnt == 1)break;
        if(cnt == 2){
            ans++;
            cnt--;
        }
        else{
            ans += 2;
            cnt -= 2;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
if N%sum(map(int, list(str(N)))) == 0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
		if(s[i]!=',')
			cout<<s[i];
		else
			cout<<" ";
	return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<atcoder/all>
#define int long long
using namespace std;
using namespace atcoder;
const int INF=1000'000'000;
signed main(){
  int N,K;
  cin>>N>>K;
  mcf_graph<int,int> G(2*N+2);
  int s=2*N,t=2*N+1;
  G.add_edge(s,t,N*K,INF);
  for(int i=0;i<N;i++){
    G.add_edge(s,i,K,0);
    G.add_edge(N+i,t,K,0);
  }
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++){
      int a;
      cin>>a;
      G.add_edge(i,N+j,1,INF-a);
    }
  cout<<N*K*INF-G.flow(s,t,N*K).second<<endl;
  vector<string> A(N,string(N,'.'));
  for(auto e:G.edges())
    if(e.from!=s && e.to!=t && e.flow)A[e.from][e.to-N]='X';
  for(string S:A)cout<<S<<endl;
}

Measured memory_bytes: 3952
import java.util.*;

class Main {
	Scanner sc;
	int H, W, K;
	String[] S;
	int[][] rc;
	
	void calc() {
		sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		K = sc.nextInt();
		S = new String[H];
		for (int i = 0; i < H; i++)
			S[i] = sc.next();
		rc = new int[W+1][H];
		for (int i = 0; i < H; i++) {
			int c = 0;
			for (int j = 0; j < W; j++) {
				if (S[i].charAt(j) == '1') c++;
				rc[j+1][i] = c;
			}
		}
		
		int n = 1 << (H-1);
		int oc = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			oc = Math.min(oc, count(i));
		}
		System.out.println(oc);
	}
	
	private int count(int bitpat) {
		int hOp = 0;
		int last = 0;
		for (int i = 0; i < W; i++) {
			if (maxCountPart(bitpat, last, i) > K) {
				hOp++;
				if (last == i) return Integer.MAX_VALUE;
				last = i;
			}
		}
		return hOp + Integer.bitCount(bitpat);
	}
	
	private int maxCountPart(int bitpat, int from, int to) {
		int max = -1;
		int c = 0;
		for (int i = 0; i < H; i++) {
			c += rc[to+1][i] - rc[from][i];
			if ( ((1<<i)&bitpat) != 0 ) {
				max = Math.max(max, c);
				c = 0;
			}
		}
		return Math.max(max, c);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 37256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <map>
using namespace std;
typedef string::const_iterator State;

string s;
int dfs(State &begin){
	int i,j;
	vector<int> list;
	begin ++;
	if(isdigit(*begin)){
		int x = 0;
		for(;isdigit(*begin);++begin) x = x*10 + *begin-'0';
		begin ++;
		return x/2+1;
	}
	while(*begin == '[') list.push_back(dfs(begin));
	begin ++;
	sort(list.begin(), list.end());
	int ret = 0;
	for(int i=0;i<list.size()/2+1;i++) ret += list[i];
	return ret; 
}

int n;
main(){
	int h,w,i,j;
	cin >> n;
	while(n--){
		cin >> s;
		State begin = s.begin();
		cout << dfs(begin) << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#%%
N, L = map(int, input().split())

aji = [L+i-1 for i in range(1, N+1)]

total = sum(aji)

if aji[0] <= 0 and 0 <= aji[-1]:
    ans = total
elif aji[-1] < 0:
    ans = total - aji[-1]
else:
    ans = total - aji[0]

print(ans)


Measured memory_bytes: 38256
fn main() {
    let (a, b, c): (usize, usize, usize) = (read(), read(), read());
    println!("{} {} {}", c, a, b);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 4352
//
// Created by 李青坪 on 2019/1/20.
//
/*
 * 坑：
 * 1.每次从栈中弹出一个长方形后，当前元素所构成的长方形的左端点要更新到弹出的长方形对应的左端点
 * 2.s的每一行需要以0结尾，否则如果一行的数值相同，就计算不出长方形面积
 */


#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>

#define MAXN 1400
#define NIL -1
using namespace std;

class Rect {
public:
    int h;
    int pos;

    Rect(int h, int pos) : h(h), pos(pos) {}
};

int H, W;
int c[MAXN][MAXN];
int s[MAXN][MAXN];

void histogram() {
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (c[i][j] == 1) {
                s[i][j] = 0;
            } else {
                s[i][j] = i > 0 ? s[i - 1][j] + 1 : 1;
            }
        }
    }
}

int findLargestRect() {
    int maxS = 0;
    for (int i = 0; i < H; ++i) {
        stack<Rect> stk;
        for (int j = 0; j <= W; ++j) {
            s[i][W] = 0;
            if (stk.empty()) {
                stk.push(Rect(s[i][j], j));
            } else if (stk.top().h < s[i][j]) {
                stk.push(Rect(s[i][j], j));
            } else if (stk.top().h > s[i][j]) {
                int pre_pos = j;
                while (stk.top().h >= s[i][j]) {
                    maxS = max(maxS, stk.top().h * (j - stk.top().pos));
                    pre_pos = stk.top().pos; //
                    stk.pop();
                    if (stk.empty()) {
                        break;
                    }
                }
                stk.push(Rect(s[i][j], pre_pos));
            }
        }
    }
    return maxS;
}

int main() {
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            scanf("%d", &c[i][j]);
        }
    }
    histogram();
    printf("%d\n", findLargestRect());
}
/*
4 5
0 0 1 0 0
1 0 0 0 0
0 0 0 1 0
0 0 0 1 0
 */


Measured memory_bytes: 18036
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
		int ans=0;
		int count=0;
		for(int i=0;i!=b.length();i++) {
			if(b.charAt(i)=='A') {
				ans=i;
				break;
			}
			}
		for(int i=b.length()-1;i!=0;i--) {
			if(b.charAt(i)=='Z') {
				count=i;
				break;
			}
		}
		System.out.println(count-ans+1);
	}
}

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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i) << ", ";
  }
  cout << "]" << endl;
}

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



Measured memory_bytes: 3116