akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define MAX 100005
#define ZERO -1 //親なし

typedef struct Node{
  int parent; 
  int left;
  int right;
}Tree;

Tree tree[MAX];

void Treeprint(int); //print関数

int main(){
  int n; //節点の個数
  int i,j; //ループカウンタ
  int id,k,child; //
  int l;

  scanf("%d", &n); //個数入力

  for(i = 0;i < n;i++){
    tree[i].parent = tree[i].left = tree[i].right = ZERO; //初期化
  }
  
  for(i = 0;i < n;i++){
    scanf("%d%d",&id,&k); //id・kの入力
    
    for(j = 0;j < k;j++){
      scanf("%d",&child); //子供・葉の入力
      tree[child].parent = id; 

      if(j == 0){
	tree[id].left = child; //左下の子供
      }
      else if(j > 0){
	tree[l].right = child; //兄弟
      }
      l = child; //兄弟
    }
  }
  for(i = 0;i < n;i++){ //出力
    Treeprint(i);
  }
  return 0;
}

void Treeprint(int n){ 

  int i = tree[n].parent; //親idの代入
  int depth = 0;
  while(i != ZERO){
    i = tree[i].parent;
    depth++;
  }
  if(depth == 0){
    printf("node %d: parent = %d, depth = %d, root, ",n,tree[n].parent,depth);
  }
  else if(tree[n].left == ZERO){
    printf("node %d: parent = %d, depth = %d, leaf, ",n,tree[n].parent,depth);
  }
  else{
    printf("node %d: parent = %d, depth = %d, internal node, ",n,tree[n].parent,depth);
  }

  i = tree[n].left;
  printf("[");
  if(i != ZERO){ //兄弟の表示
    printf("%d",i);
  }
  while(i != ZERO){ 
    i = tree[i].right;

    if(i != ZERO){
      printf(", %d", i);
    }
  }
  printf("]\n");
}

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

const int N = (int) 1e5;
int deg[N];

int main() {
	int n; cin >> n;
	int m; cin >> m;
	for (int i = 0; i < m; ++i) {
		int u, v; cin >> u >> v; --u; --v;
		++deg[u]; ++deg[v];
	}
	bool res = true;
	for (int i = 0; i < n; ++i) {
		res = res && deg[i] % 2 == 0;
	}
	cout << (res ? "YES" : "NO") << endl;
}


Measured memory_bytes: 640
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

void solve(long long N) {
  rep(i,  2 * N)
  {
    double j = i;
    int k = (int)(j * 1.08);
    if(k==N)
    {
      cout << i << endl;
      return;
    }
  }
  cout << ":("<<endl;
}

int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
from itertools import permutations
import math

items = [int(input()) for i in range(5)]

items_list = list(permutations(items))
time = float('inf')



for i in range(len(items_list)):
    tmp = 0
    for j in range(4):
        tmp += math.ceil(items_list[i][j] / 10) *10
    
    tmp += items_list[i][4]
    time = min(time, tmp)

print(time)

Measured memory_bytes: 3064
H, W, D = map(int,input().split())
L = [[0,0] for _ in range(H*W+1) ]
for i in range(H):
    s = input().split()
    cnt = 0
    for x in s:
        L[int(x)]=[i,cnt]
        cnt += 1
M = [[0,0] for _ in range(H*W+1)]
for i in range(D,len(L)):
    M[i][0] = abs(L[i-D][0] - L[i][0])
    M[i][1] = abs(L[i-D][1] - L[i][1]) 
for i in range(D,len(L)):
    M[i][0] = M[i][0] + M[i-D][0]
    M[i][1] = M[i][1] + M[i-D][1]    
Q = int(input())
for i in range(Q):
    ans = 0
    x,y = map(int,input().split())
    ans += M[y][0] - M[x][0] 
    ans += M[y][1] - M[x][1]
    print(ans)


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

set<char> r{'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};
string s;

void solve() {
  bool st = (r.find(s[0]) != r.end() ? 1 : 0);
  int cnt = 0;

  for(int i = 0; i < s.length(); ++i) {
    if(r.find(s[i]) != r.end()) {
      if(!st) cnt++;
      st = 1;
    }
    else {
      if(st) cnt++;
      st = 0;
    }
  }
  cout << cnt << endl;
}

int main() {
  while(cin >> s) {
    if(s == "#") break;
    solve();
  }
  return 0;
}



Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());


		int count = 0;

		for (int i = 0; i < 2 ; i++) {
			if(a > b) {
				count += a;
				a--;
			} else {
				count += b;
				b--;
			}
		}

		System.out.println(count);
	}
}

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

using namespace std;

int c[] = {-1, -1, -1, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, m; cin >> n >> m;
  string res;

  int pos, val;
  while (m--) {
    cin >> pos >> val;
    if ((c[pos] >= 0 && c[pos] != val) || (n > 1 && pos == 1 && val == 0)) {
      res = "-1";
    }
    c[pos] = val;
  }

  if (res.size() == 0) {
      for (pos = 1; pos <= n; ++pos) 
        if (c[pos] >= 0)
          res += (char)('0' + c[pos]);
        else {
          int first = pos == 1 && n > 1 ? 1 : 0;
          res += (char)('0' + first);
        }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
using System;

namespace ABC042_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();

            if (line == "5 5 7" ||
                line == "5 7 5" ||
                line == "7 5 5")
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 13140
n = int(input())

arr = []

for i in range(n):
	arr.append(int(input()))

arr.sort()

ans = sum(arr)

if ans%10 == 0:
	ind = 0
	while  ind < n and arr[ind] % 10 == 0:
		ind += 1

	if ind == n:
		print 0

	else :
		print ans - arr[ind]
else:
	print ans

Measured memory_bytes: 2568
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        --a[i];
    }
    vector<int> s(n+1);
    rep(i,n) {
        s[i+1] = (s[i]+a[i])%k;
    }
    ll ans = 0;
    map<int,int> mp;
    queue<int> q;
    rep(i,n+1) {
        ans += mp[s[i]];
        ++mp[s[i]];
        q.push(s[i]);
        if (!(q.size()<k)) {
            --mp[q.front()];
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12032
function Main(input) {
  var ab = input.split(" ");
  ab[0] = parseInt(ab[0]);
  ab[0] = parseInt(ab[0]);
  if(ab[0]==1){
    ab[0]=14;
  }
  if(ab[1]==1){
    ab[1]=14;
  }
  if (ab[0] > ab[1]) {
    process.stdout.write("Alice");
  } else if (ab[0] < ab[1]) {
    process.stdout.write("Bob");
  } else {
    process.stdout.write("Draw");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a > b) cout << "a > b" << endl;
  if(a < b) cout << "a < b" << endl;  
  if(a == b) cout << "a == b" << endl; 
  return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n),l(n+1),r(n+1);
    fr(i,n) cin>>a[i];
    fr(i,n) l[i+1]=max(l[i],a[i]);
    ifr(i,n) r[i]=max(r[i+1],a[i]);
    fr(i,n) cout<<max(l[i],r[i+1])<<endl;
}

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

int main(){
	int n;
	cin>>n;
	int x=n%10;
	if(x==2 || x==4 || x==5 || x==7 || x==9){
		cout<<"hon";
	}
	else if(x==0 || x==1 || x==6 || x==8){
		cout<<"pon";
	}
	else{
		cout<<"bon";
	}
	return 0;
}

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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		vector<int>b(n);
		rep(i, n)scanf("%d", &b[i]);
		for (int cnt = 0;; cnt++) {
			if (cnt > 10000) {
				puts("-1"); break;
			}
			bool ok = true;
			rep(i, b.size()) {
				if (b[i] != i + 1)ok = false;
			}
			if (ok) {
				printf("%d\n", cnt); break;
			}
			rep(i, b.size())b[i]--;
			b.push_back(b.size());
			b.erase(remove(b.begin(), b.end(), 0), b.end());
		}
	}
}

Measured memory_bytes: 3244
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<int>v(N + 1);
	vector<vector<int>>sum(M + 1, vector<int>(N + 1));
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}
	for (int i = 1; i <= N; i++) {
		sum[v[i]][i]++;
		for (int j = 1; j <= M; j++) {
			sum[j][i] += sum[j][i - 1];
		}
	}
	vector<int>dp(1 << M, MOD);
	dp[0] = 0;
	for (int i = 0; i < 1 << M; i++) {
		int used = 0;
		for (int j = 0; j < M; j++) {
			if ((i >> j) & 1) {
				used += sum[j + 1][N];
			}
		}
		for (int j = 0; j < M; j++) {
			if ((i >> j) & 1)continue;
			dp[i + (1 << j)] = min(dp[i + (1 << j)], dp[i] + sum[j + 1][N] - (sum[j + 1][used + sum[j + 1][N]] - sum[j + 1][used]));
		}
	}
	cout << dp[(1 << M) - 1] << endl;
	return 0;
}



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

int main(){
	int R;
	cin >> R;
	
	if(R < 1200){
		cout << "ABC" << endl;
	}
	
	if(1200 <= R && R < 2800){
		cout << "ARC" << endl;
	}
	
	if(R >= 2800) {
		cout << "AGC" << endl;
	}
	
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad

main = do
    xs <- map read <$> words <$> getLine :: IO [Integer]
    if all (== 0) xs then return ()
    else do
        let [a1,_,a2,_,a3,_] = xs
            [_,m1,_,m2,_,m3] = xs
            as = [a1,a2,a3]
            ms = [m1,m2,m3]
            cycles = zipWith solve as ms
        print $ foldr1 lcm cycles
        main

solve :: Integer -> Integer -> Integer
solve a m = rec 1 $ a `mod` m
    where rec c 1 = c
          rec c x = rec (c+1) $ (a*x) `mod` m

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


class Dice{
    public : int diceNum[6];

    public : void set(int Num,int label){
        diceNum[label] = Num;
    };

    public : void roll(char label){
        switch (label)
        {
        case 'E':
            setAll(diceNum[3],diceNum[1],diceNum[0],diceNum[5],diceNum[4],diceNum[2]);
            break;
        case 'N':
            setAll(diceNum[1],diceNum[5],diceNum[2],diceNum[3],diceNum[0],diceNum[4]);
            break;
        case 'S':
            setAll(diceNum[4],diceNum[0],diceNum[2],diceNum[3],diceNum[5],diceNum[1]);
            break;
        case 'W':
            setAll(diceNum[2],diceNum[1],diceNum[5],diceNum[0],diceNum[4],diceNum[3]);
            break;
        }
    };
    public : int upNum(){
        return diceNum[0];
    }
    public : int frontNum(){
        return diceNum[1];
    }
    public : int rightNum(){
        return diceNum[2];
    }
    
    public : int Num(int Num){
        return diceNum[Num];
    }


    private : void setAll(int a1,int a2,int a3,int a4,int a5,int a6){
        set(a1,0);
        set(a2,1);
        set(a3,2);
        set(a4,3);
        set(a5,4);
        set(a6,5);
    };
};

bool Checker(Dice diceA,Dice diceB){
    bool check = true;
    for(int i=0;i<6;i++){
        if(diceA.Num(i) != diceB.Num(i)){
            check = false;
        }
    }
    return check;
}

bool checkerMother(Dice diceA,Dice diceB){


    //printf("                                                                   %d %d\n",checkNum[0],checkNum[1]);
    for(int j = 0;j < 4;j++){
        //printf("  %d %d %d %d %d %d\n",diceB.diceNum[0],diceB.diceNum[1],diceB.diceNum[2],diceB.diceNum[3],diceB.diceNum[4],diceB.diceNum[5]);

        if(diceA.frontNum() == diceB.frontNum()){
            break;
        }
        diceB.roll('S');
    }

    if(diceA.frontNum() != diceB.frontNum()){
        diceB.roll('W');
        diceB.roll('S');
        //printf("                                                                   %d\n",dice.frontNum());
        if(diceA.frontNum() != diceB.frontNum()){
            diceB.roll('S');
            diceB.roll('S');
        }
    }

    //printf("  %d %d %d %d %d %d\n",diceB.diceNum[0],diceB.diceNum[1],diceB.diceNum[2],diceB.diceNum[3],diceB.diceNum[4],diceB.diceNum[5]);

    if(diceA.frontNum() != diceB.frontNum()){
        return false;
    }

    for(int i = 0;i< 4;i++){
        diceB.roll('W');
        if(Checker(diceA,diceB)){
            return true;
        }
    }

    
    return false;
}


int main(){
    
    int Num;
    scanf("%d",&Num);

    Dice dice[Num];

    for(int j =0;j<Num;j++){
        for(int i = 0;i<6;i++){
            int diceNum;
            scanf("%d",&diceNum);
            dice[j].set(diceNum,i);
        }
    }

    for(int i = 0;i<Num;i++){
        for(int j = i+1;j<Num;j++){
            if(checkerMother(dice[i],dice[j])){
                printf("No\n");
                return 0;
            }
        }
    }




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



Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[2010],ans;
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++)
		for (int j=i+1;j<n;j++)
			if (a[i]>a[j]) ans++;
	ans*=m;ans%=1000000007;
	for (int i=0;i<n;i++){
		long long num=0;
		for (int j=0;j<n;j++) if (a[i]>a[j]) num++;
		ans=(ans+num*((m*(m-1)/2)%1000000007))%1000000007;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int N;
	cin >> N;

	bool flag = false;

	//iは4ドルのケーキ
	//jは７ドルのドーナツ

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (4 * i + 7 * j == N) {
				flag = true;
				break;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    string a,s,c;
    cin >> a >> s >> c;
    cout << "A" << s[0] << "C" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

bool nabeatu(int num) {
  if (num % 3 == 0) {
    return true;
  }
  while (num > 1) {
    if (num % 10 == 3) {
      return true;
    }
    num /= 10;
  }
  return false;
}

int main () {
  int n;
  std::cin >> n;
  for (int i = 1; i <= n; i++) {
    if (nabeatu(i)) {
      std::cout << " " << i;
    }
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 3092
func :: Int -> Int -> Int
func k s = sum 
  $ map (\x -> 1)
  $ filter (\x -> x >= 0 && x <= k)
  [s - (a + b) | a <- [0..k], b <- [0..k]]

main = do
  line <- getLine
  let
    [k,s] = map read $ words line :: [Int]
    ans = func k s
  putStrLn $ show ans


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007; // 1e9 + 7
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
template <class T> inline bool chmin(T &a, T b) { if ( a > b ) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T &a, T b) { if ( a < b ) { a = b; return 1; } return 0; }
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

ll N;

int main(int argc, char *argv[]){
    cin >> N;
    string res = "";
    while(N){
        int r = N % 2;
        if(r < 0) r += 2;
        N = (N - r) / (-2);
        res += (char)('0' + r);
    }
    reverse(all(res));
    if(res == "") res = "0";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int D[10];
int main()
{
  int N, K;
  ios::sync_with_stdio(false);
  cin >> N >> K;
  for( int i=0; i<K; i++ ){
    int d;
    cin >> d;
    D[d]++;
  }
  while( 1 ){
    int n = N;
    int f = 1;
    while( n > 0 ){
      if( D[n%10] ){ f = 0; break; }
      n /= 10;
    }
    if( f ){ cout << N << endl; return 0; }
    N++;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int n,x,y,ans;
int main()
{
	char a[3];
	while(scanf("%d",&n)!=EOF)
	{
		ans=0;
		for(int i=0;i<n;i++)
		{
			scanf("%d%d",&x,&y);
			ans+=(y-x+1);
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

 int main () {
   int x, a, b;
   cin >> x >> a >> b;
   
   if (b-a<=0) {
     cout << "delicious" << endl;
   }
   else if (b-a<=x) {
     cout << "safe" << endl;
   }
   else {
     cout << "dangerous" << endl;
   }
 }


Measured memory_bytes: 3588
#include <stdio.h>
 
int main(void){
  int a[3][3];
  int n;
  int b[101];
  int c[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
    	c[i][j]=0;
    }
  }
  for(int i=0; i<3; i++){
    scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
  }
  scanf("%d",&n);
  for(int i=0; i<n; i++){
    scanf("%d",&b[i]);
    if(b[i]==a[0][0])
        c[0][0]=1;
	if(b[i]==a[0][1])
        c[0][1]=1;
    if(b[i]==a[0][2])
        c[0][2]=1;
    if(b[i]==a[1][0])
        c[1][0]=1;
    if(b[i]==a[1][1])
        c[1][1]=1;
    if(b[i]==a[1][2])
        c[1][2]=1;
    if(b[i]==a[2][0])
        c[2][0]=1;
    if(b[i]==a[2][1])
        c[2][1]=1;
    if(b[i]==a[2][2])
        c[2][2]=1;
  }
  if(c[0][0]==1&&c[0][1]==1&&c[0][2]||
     c[1][0]==1&&c[1][1]==1&&c[1][2]||
     c[2][0]==1&&c[2][1]==1&&c[2][2]||
     c[0][0]==1&&c[1][0]==1&&c[2][0]||
     c[0][1]==1&&c[1][1]==1&&c[2][1]||
     c[0][2]==1&&c[1][2]==1&&c[2][2]||
     c[0][0]==1&&c[1][1]==1&&c[2][2]||
     c[0][2]==1&&c[1][1]==1&&c[2][0]){
	printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if(c >= a)
    {
        if(b >= c)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else
    {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#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<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int p,q,r;cin >> p >> q >> r;
    int ans=INF;
    ans = min(ans,p+q);
    ans = min(ans,p+r);
    ans = min(ans,r+q);
    cout << ans << endl;
    return 0;
}



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

namespace _0532
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int D = 0; D < 3; D++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int a1 = a[0] * 3600 + a[1] * 60 + a[2];
                int a2 = a[3] * 3600 + a[4] * 60 + a[5];
                int ax = a2 - a1;
                int[] at = new int[8];
                at[0] = ax / 3600;
                at[1] = (ax % 3600) / 60;
                at[2] = ax - at[0] * 3600 - at[1] * 60;
                Console.WriteLine(at[0] + " " + at[1] + " " + at[2]);
            }
        }
    }
}

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> x(N);
	REP(i, N) scanf("%d", &x[i]);
	sort(ALL(x));
	
	int ans = abs(X - x[0]);
	FOR(i, 1, N) ans = gcd(ans, abs(x[i] - x[i - 1]));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) 
{
	int b = 0;
	int f = 0;
	int r = 0;
	int v = 0;
	int n = 0;
	int i = 0;
	int j = 0;
	int k = 0;
	
	unsigned int room[4][3][10];
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 3; j++)
		{
			for(k = 0; k < 10; k++)
			{
				room[i][j][k] = 0;
			}
		}
	}
	
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);
		room[b - 1][f - 1][r - 1] += v;
	}
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 4; j++)
		{
			for(k = 0; k < 10; k++)
			{
				if(j < 3)
				{
					printf(" %d", room[i][j][k]);
				}
				if(j == 3 && i < 3)
				{
					printf("##");
					if(k == 9)
					{
						printf("\n");
					}
				}
				if(k == 9 && j < 3 && i < 4)
				{
					printf("\n");
				}
			}
		}
	}
	return 0;
}

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

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

    int cost1 = 0;
    int cost2 = 0;
    int cost3 = 0;
    int cost4 = 0;
    int cost5 = 0;
    int cost6 = 0;


    cost1 = abs(b - a) + abs(c - b);
    cost2 = abs(c - a) + abs(b - c);
    cost3 = abs(a - b) + abs(c - a);
    cost4 = abs(c - b) + abs(a - c);
    cost5 = abs(a - c) + abs(b - a);
    cost6 = abs(b - c) + abs(a - b);

    int cost = cost1;
    if (cost2 < cost) cost = cost2;
    if (cost3 < cost) cost = cost3;
    if (cost4 < cost) cost = cost4;
    if (cost5 < cost) cost = cost5;
    if (cost6 < cost) cost = cost6;

    cout << cost << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>
 
using namespace std;
typedef long long ll;
 
int main() {
  string S;
  cin >> S;
  int N = S.size();
 
  int dp[N + 1][13];
  memset(dp, 0, sizeof(dp));
 
  if (S[N - 1] == '?') {
    for (int i = 0; i < 10; ++i) {
      dp[1][i] = 1;
    }
  } else {
    int i = S[N - 1] - '0';
    dp[1][i] = 1;
  }
 
  int base = 10;
  int MOD = 1000000007;
 
  for (int idx = 1; idx < N; ++idx) {
    char s = S[N - idx - 1];
    int n = s - '0';
 
    if (s == '?') {
      for (int i = 0; i < 13; ++i) {
        for (int j = 0; j < 10; ++j) {
          int k = (i + (j * base) % 13) % 13;
          dp[idx + 1][k] = (dp[idx + 1][k] + dp[idx][i]) % MOD;
        }
      }
    } else {
      for (int i = 0; i < 13; ++i) {
        int j = (i + (n * base) % 13) % 13;
        dp[idx + 1][j] = (dp[idx + 1][j] + dp[idx][i]) % MOD;
      }
    }
 
    base = (base * 10) % 13;
  }
 
  cout << dp[N][5] << endl;
 
  return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int N, W;
    cin>>N>>W;
    vector<long long> w(N), v(N);
    vector<vector<long long>> dp(N+1, vector<long long>(W+1,0));
    for(int i = 0; i<N; i++)
    {
        cin>>w[i]>>v[i];
    }
    for(int i = 1; i<=N; i++)
    {
        for(int j = 1; j<=W; j++)
        {
            if(w[i-1] <= j)
            {
                dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][j - w[i-1]]);
            }
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    // for(auto j : dp)
    // {
    //     for(auto i : j)
    //         cout<<i<<" ";
    //     cout<<"\n";
    // }
    
    
    cout<<dp[N][W]<<"\n";
	return 0;
}


Measured memory_bytes: 83132
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    double c = 1.0 * a/b;

    System.out.println((int) a / b + " " + a % b + " " + String.format("%.8f", c));

  }
}


Measured memory_bytes: 26364
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        String a = scan.next();
        String cnt;
        
        int sum = 0;
        
        for( int i = 0 ; i < a.length() ; i++ ){
          int s2integ = Integer.parseInt(a.substring(i,i+1));
          sum += s2integ;
        }
        
        int s_num = Integer.parseInt( a );
        
        if( s_num % sum == 0 )cnt = "Yes";
        else cnt = "No";
            
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <climits>
#define PASTA 3
#define JUICE 2
#define OFF 50

using namespace std;

int main(){
  int pa[ PASTA ];
  int ju[ JUICE ];
  int i, j;
  int min = INT_MAX;
  
  cin >> pa[ 0 ] >> pa[ 1 ] >> pa[ 2 ] >> ju[ 0 ] >> ju[ 1 ];

  for( int i = 0; i < PASTA; i++ ){
    for( int j = 0; j < JUICE; j++ ){
      int price = pa[ i ] + ju[ j ] - OFF;
      if( price < min ){ min = price; }
    }
  }

  cout << min << endl;

  return 0;
}

Measured memory_bytes: 0
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int[][] cnt = new int[N][N];
        for (int i = 0; i < M; i++) {
            int l = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            cnt[l][r]++;
        }
        for (int i = N - 2; i >= 0; i--)
            for (int j = 0; j < N; j++)
                cnt[i][j] += cnt[i + 1][j];
        for (int i = 1; i < N; i++)
            for (int j = 0; j < N; j++)
                cnt[j][i] += cnt[j][i - 1];
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < Q; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            pw.println(cnt[p][q]);
        }
        pw.close();
        sc.close();
    }
}

Measured memory_bytes: 155844
#include <iostream>

using namespace std;

int main()
{

    int income,expense,month,tmp,cost;
    bool f;

    while(true){
        cin >> cost;
        if(cost == 0){
            break;
        }

        tmp = 0;
        f = false;
        month = 0;

        for(int i = 0; i < 12; ++i){
            income = 0;
            expense = 0;

            cin >> income >> expense;

            tmp += (income - expense);
//            cout << tmp << endl;
            if(tmp >= cost && !f){
                month = i+1;
                f = true;
//                cout << month << endl;
            }
        }

        if(month == 0){
            cout << "NA" << endl;
        }
        else{
            cout << month << endl;
        }
    }

}

Measured memory_bytes: 1160
from math import factorial
def com(n,r):
    if n<r:
        return 0
    return int(factorial(n) // factorial(r) // factorial(n-r))

def main():
    n = int(input())
    str_list = [input() for _ in range(n)]

    count = 0

    for i,s in enumerate(str_list):
        str_list[i] = sorted(s)

    str_list = sorted(str_list)

    i = 0
    j = 1
    while i < n:
        tmp = 0
        while i + j < n and str_list[i] == str_list[i + j]:
            tmp += 1
            j += 1
        if tmp != 0:
            count += com(tmp+1, 2)
        i += j
        j = 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 116824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int N;
  	cin >> N;
  	int fn = 0;
  
  for (int i = 0; i < 8; i++) {
  	int ten = 1;
    for (int j = 0; j < i; j++) { //10の累乗を作っている
    	ten *= 10;
    }
   
    int s = N / ten % 10; //Nの各桁
    fn += s;
  
  }
  
  int H = N % fn;//　Nがfnで割り切れるか
  
  if (H == 0) {
    cout << "Yes" << endl; 	  
  }
  else {
  	cout << "No" << endl;
  }
  
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {

	int r, D, x[11];
	scanf("%d %d %d", &r, &D, &x[0]);

	for (int i = 0; i < 10; i++) {
		x[i + 1] = r * x[i] - D;
		printf("%d\n", x[i + 1]);
	}
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

long long int solve(long long int h, long long int w)
{
	long long int ans = mod;
	for(int i = 1; i < h; i++){
		long long int tmp1 = w * ((h - i) / 2 + (h - i) % 2);
		long long int tmp2 = (w / 2 + w % 2) * (h - i);
		ans = min(ans, max(w * i, min(tmp1, tmp2)) - min(w * i, w * (h - i) - min(tmp1, tmp2)));
	}
	return ans;
}

int main()
{
	int h, w;
	cin >> h >> w;
	cout << min(solve(h, w), solve(w, h)) << endl;
	return 0;
}

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

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

  if(b-a==c-b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main(void){

	int n, money;
	cin>>n;
	money = 100000;
	for (int i=0; i<n; i++){
		money = ceil(((double)money * 1.05)/1000)*1000;
	}
	cout<<money<<endl;
	return 0;
} 

Measured memory_bytes: 1164
#include<iostream>      
#include<cstdio>    
#include<stdio.h>    
#include<cstring>      
#include<cstdio>      
#include<climits>      
#include<cmath>     
#include<vector>    
#include <bitset>    
#include<algorithm>      
#include <queue>    
#include<map>    
#include<stack>  
using namespace std;  
  
long long int ans1, ans2, sum1, sum2;  
int n, i;  
long long int a[100005];  
int main()  
{  
    cin >> n;  
    for (i = 1; i <= n; i++)  
    {  
        cin >> a[i];  
    }  
    if (a[1] >0)  
    {  
        sum1 = a[1];  
        ans2= a[1] + 1;  
        sum2 = -1;  
    }  
    else if (a[1] == 0)  
    {  
        sum1 = 1;  
        ans1 = ans2 = 1;  
        sum2 = -1;  
    }  
    else   
    {  
        sum1 = 1;  
        ans1 = abs(a[1]) + 1;  
        sum2 = a[1];  
    }  
    for (i = 2; i <= n; i++)  
    {     
        if (sum1 > 0)  
        {  
            if (a[i] + sum1 >= 0)  
            {  
                ans1 += a[i] + sum1 + 1;  
                sum1 = -1;  
            }  
            else  
            {  
                sum1 += a[i];  
            }  
        }  
        else  
        {  
            if (a[i] + sum1 <= 0)  
            {  
                ans1 += abs(sum1 + a[i]) + 1;  
                sum1 = 1;  
            }  
            else  
            {  
                sum1 += a[i];  
            }  
        }  
    }  
    for (i = 2; i <= n; i++)  
    {  
        if (sum2 > 0)  
        {  
            if (a[i] + sum2 >= 0)  
            {  
                ans2 += a[i] + sum2 + 1;  
                sum2 = -1;  
            }  
            else  
            {  
                sum2 += a[i];  
            }  
        }  
        else  
        {  
            if (a[i] + sum2 <= 0)  
            {  
                ans2 += abs(sum2 + a[i]) + 1;  
                sum2 = 1;  
            }  
            else  
                sum2 += a[i];  
        }  
    }  
    cout << min(ans1, ans2) << endl;  
}  

Measured memory_bytes: 1024
import itertools
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
nn = [i+1 for i in range(n)]
mm = list(itertools.permutations(nn))
print(max((mm.index(q)) - (mm.index(p)) , (mm.index(p)) - mm.index(q)))

Measured memory_bytes: 8052
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
vector<int> E[200001];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;
vector<int> ans(200001);

void solve(int start,int parent) {
    for (int v : E[start]) {
        if (v == parent) continue;
        ans[v] += ans[start];
        solve(v, start);
    }
}

int main() {
    int N, Q; cin >> N >> Q;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    //予め根にカウントを足しておく
    for (int i = 0; i < Q; i++) {
        int v, s;
        cin >> v >> s;
        ans[v] += s;
    }

    solve(1, -1);

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


Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
using ll = long long;
const int N = 2e6 + 15;
int main(){
	int n, m, x;
	cin >> n >> m >> x;
	int c[n];
	int a[n][m];
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
		}
	}
	int tot = (1 << n);
	int ok = 0;
	int mini = 2e9;
	for (int mask = 0; mask <= tot; ++mask) {
		vector<int> have(m, 0);
		int cost = 0;
		for (int i = 0; i < n; ++i) {
			if (mask & (1 << i)) {
				cost += c[i];
				for (int j = 0; j < m; ++j) {
					have[j] += a[i][j];
				}
			}
		}
		int f = 1;
		for (int i = 0; i < m; ++i) 
		if (have[i] < x) f = 0;
		if (f) {
			if (ok == 0 || mini > cost) {
				ok = 1;
				mini = cost;
			}
		}
	}
	if (!ok) {
		cout << "-1\n";
	}else {
		cout << mini << "\n";
	}
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
	char* s = (char*)calloc(11,sizeof(char));
	cin >> s;
	
	char* t = (char*)calloc(12,sizeof(char));
	cin >> t;
	
	bool ans = true;
	while(*s != 0){
		if(*t != *s) ans = false;
		t++;
		s++;
	}
	if(ans) cout << "Yes";
	else cout << "No";
	cout << endl;
}


Measured memory_bytes: 3560
N, A, B = map(int, raw_input().split())
S = raw_input()
acc_b = 0
acc_t = 0
for x in range(N):
    app = S[x]
    under = (acc_t < (A + B))
    if app == "a" and under:
        print "Yes"
        acc_t += 1
    elif app == "b" and acc_b < B and under:
        print "Yes"
        acc_t += 1
        acc_b += 1
    else:
        print "No"
    

Measured memory_bytes: 6276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int r = 0;
  cin >> r;
  double res = 0;
  res = r * 2 * 3.14159265;
  cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 3788
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int[] stair = new int[n+1];
    int mod = 1_000_000_007;
    for(int i=0;i<m;i++){
      stair[Integer.parseInt(sc.next())] = -1;
    }
    stair[0] = 1;
    for(int i=1;i<=n;i++){
      if(stair[i]==-1)continue;
      if(i>1){
        if(stair[i-2]!=-1)stair[i]+=stair[i-2];
        if(stair[i-1]!=-1)stair[i]+=stair[i-1];
        stair[i] = stair[i]%mod;
      }else{
        stair[i]+=1;
      }
    }
    System.out.print(stair[n]);
    System.out.flush();
  }
}

Measured memory_bytes: 43568
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

int n,k;
int cnt[200001];
int ans = 0;

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a-1]++;
    }

    sort(cnt,cnt+n);
    
    for(int i = 0; i < n-k; i++){
        ans += cnt[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  size_t sz=s.size();
  for(int i=0;i<sz;i++)if(((s[i]=='L')&(~i&1))||((s[i]=='R')&(i&1))){cout<<"No"<<endl;return 0;}
  cout<<"Yes"<<endl;
  return 0;
}


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

int main() {
  int N;
  scanf("%d",&N);
  int f_n=0;
  int n=N;
  while (N>0) {
    f_n+=N%10;
    N/=10;
  }
  if (n%f_n==0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// gcd, lcm
ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}


int main() {
    ll n, k;
    cin >> n >> k;
    if (2 * n < k) {
        cout << 0;
        return 0;
    }
    if (k % 2 == 1) {
        ll ans = (n / k) * (n / k) * (n / k);
        cout << ans;
        return 0;
    } else {
        if (n * 2 < (((n/k) * 2) + 1) * k) {
            ll ans = 2 * (n / k) * (n / k) * (n / k);
            cout << ans;
        } else {
            ll ans = (n / k) * (n / k) * (n / k) + (n / k + 1) * (n / k + 1) * (n / k + 1);
            cout << ans;
        }
        return 0;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<ll>> gcds(2, vector<ll>(n - 1));
  rep(dir, 2) {
    gcds[dir][0] = a[0];
    rep(i, n - 2) {
      gcds[dir][i + 1] = gcd(gcds[dir][i], a[i + 1]);
    }
    if(dir == 0) reverse(all(a));
  }

  ll ans = max(gcds[0][n - 2], gcds[1][n - 2]);
  for(int i = 1; i < n - 1; i++) {
    ans = max(ans, gcd(gcds[0][i - 1], gcds[1][n - i - 2]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
//itp1_topic3_d
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin>>a>>b>>c;
  int cnt = 0;
  for(int x = a; x <= b; x++){
    if(c % x == 0) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int r;
  cin>>r;

  cout<<3*pow(r,2)<<endl;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    A = list(map(int,input().split()))
    zougen = [-1 if A[i] > A[i + 1] else 1 for i in range(N - 1)]
    money = 1000
    kabu = 0
    for i in range(N-1):
        if zougen[i] == 1:
            kabu += money // A[i]
            money = money % A[i]
        else:
            money += kabu * A[i]
            kabu = 0
    print(A[-1] * kabu + money)



if __name__ == "__main__":
    main()

Measured memory_bytes: 8936
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
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 rec(int n,vector<int> &dp) {
	if (n == 0) {
		return dp.at(n) = 0;
	}
	if (dp.at(n) < INT_MAX) {
		return dp.at(n);
	}
	chmin(dp.at(n), rec(n - 1, dp) + 1);
	for (int i = 1; pow(6, i) <= n; i++) {
		chmin(dp.at(n), rec(n - pow(6, i), dp) + 1);
	}
	for (int i = 1; pow(9, i) <= n; i++) {
		chmin(dp.at(n), rec(n - pow(9, i), dp) + 1);
	}
	return dp.at(n);
}

int main() {
	int n; cin >> n;
	vector<int> dp(n + 1,INT_MAX);//0~n
	cout << rec(n, dp) << endl;
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <stdint.h>
using namespace std;

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

    int32_t sum = 0;
    int32_t min_s = INT32_MAX;
    for (int32_t i = 0; i < n; i++) {
        int32_t s;
        cin >> s;
        if (s % 10 != 0 && s < min_s) {
            min_s = s;
        }
        sum += s;
    }
    if (sum % 10 != 0) {
        cout << sum << endl;
    } else if (min_s == INT32_MAX) {
        cout << 0 << endl;
    } else {
        cout << sum - min_s << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    int n,a,b,c;
    cin>>n;
    a=n/1000;
    n%=1000;
    b=n/100;
    n%=100;
    c=n/10;
    n%=10;
    if((a==b && a==c && b==c && a!=n) || (b==n && c==n && b==c && a!=n) || (a==b && a==c && a==n && b==c && b==n && c==n)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
s = [list(map(str, list(str(input())))) for i in range(H)]
List = [[0] * W for i in range(H)]

num = 1

for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            List[i][j] = num
            num += 1

# print(List)
one_flag = False

for i in range(H):
    first = -1
    for j in range(W):
        if List[i][j] != 0 and first == -1:
            first = List[i][j]
            for k in range(j):
                if List[i][k] == 0:
                    List[i][k] = List[i][j]

        elif List[i][j] != 0 and first != -1:
            first = List[i][j]

        elif List[i][j] == 0 and first != -1:
            List[i][j] = first

start = 0

for i in range(H):
    if List[i][0] != 0:
        start = i
        break

for j in range(W):
    for i in reversed(range(1, start+1)):
        List[i - 1][j] = List[i][j]

for i in range(start + 1, H):
    for j in range(W):
        if List[i][j] == 0:
            List[i][j] = List[i - 1][j]

for i in range(H):
    for j in range(W):
        if j != W - 1:
            print(List[i][j], end=" ")
        else:
            print(List[i][j])



Measured memory_bytes: 57176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 998244353
typedef long long ll;
using namespace std;

int N,M;
int A[303][303];

int Gauss(){
    int rank=0;
    for(int j=0;j<M;j++){
        int pivot=-1;
        for(int i=rank;i<N;i++){
            if(A[i][j]){
                pivot=i;
                break;
            }
        }

        if(pivot>=0){
            if(pivot!=rank){
                for(int k=0;k<M;k++) swap(A[pivot][k],A[rank][k]);
            }
            for(int i=rank+1;i<N;i++){
                if(A[i][j]){
                    for(int k=0;k<M;k++) A[i][k]^=A[rank][k];
                }
            }
            rank++;
        }
    }
    return rank;
}

ll my_pow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n/=2;
    }
    return res;
}

int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++) for(int j=0;j<M;++j) cin>>A[i][j];

  int rank=Gauss();

  ll ans=my_pow(2ll,N-1+M)-my_pow(2ll,N-1+M-rank);
  ans=(ans+MOD)%MOD;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640