akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(a)  begin(a),end(a)
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef long long unsigned int llu;


/*---------------------------------------------------------------------------------*/


int main(){
   int h,w;
   scanf("%d %d",&h,&w);
   char a[h+2][w+1] = {};
   FOR(i,1,h+1){
     scanf("%s",&a[i]);
   }
   int sum;
   FOR(i,1,h+1){
     rep(j,w){
       if(a[i][j]=='.'){
        sum=0;
        if(j==0){
          if(a[i-1][j]=='#') sum++;
          if(a[i+1][j]=='#') sum++;
          if(a[i+1][j+1]=='#') sum++;
          if(a[i][j+1]=='#') sum++;
          if(a[i-1][j+1]=='#') sum++;
        }
        else{
          if(a[i-1][j]=='#') sum++;
          if(a[i-1][j-1]=='#') sum++;
          if(a[i][j-1]=='#') sum++;
          if(a[i+1][j-1]=='#') sum++;
          if(a[i+1][j]=='#') sum++;
          if(a[i+1][j+1]=='#') sum++;
          if(a[i][j+1]=='#') sum++;
          if(a[i-1][j+1]=='#') sum++;
        }
          a[i][j] = '0'+sum;
       }
     }
   }
   FOR(i,1,h+1){
     printf("%s\n",&a[i]);
   }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);
const int MAXN = 1e5+5;
vector<P> v[MAXN];
const int INF = 0x3f3f3f3f;
int dis[MAXN];
int to[MAXN];
void dijkstra(int st)
{
    priority_queue<P, vector<P>, greater<P> > q;
    memset(dis, INF, sizeof(dis));
    dis[st] = 0;
    q.push(P(0, st));
    while(!q.empty())
    {
        P now = q.top();
        q.pop();
        if(dis[now.second] < now.first) continue;
        for(int i = 0; i < v[now.second].size(); i++)
        {
            P next = v[now.second][i];
            if(dis[next.second] > dis[now.second] + next.first)
            {
                to[next.second] = now.second;
                dis[next.second] = dis[now.second] + next.first;
                q.push(P(dis[next.second], next.second));
            }
        }
    }
}

int main()
{
    //FIN;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int st, ed, w;
        cin >> st >> ed;
        v[st].push_back(P(1, ed));
        v[ed].push_back(P(1, st));
    }   
    dijkstra(1);
    // for(int i = 2; i <= n; i++)
    // {
    //     cout << to[i] << ' ';
    // }
    // cout << endl;
    // for(int i = 2; i <= n; i++)
    // {
    //     cout << dis[i] << ' ';
    // }
    // cout << endl;
    int flg = 1;
    for(int i = 2; i <= n; i++)
    {
        if(!to[i]) flg = 0;
    }
    if(flg)
    {
        cout << "Yes" << endl;
        for(int i = 2; i <= n; i++)
        {
            cout << to[i] << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 13208
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Program{
    public static void Main(){
        int sum_n = 0;
        string S = ReadLine();
        int N = int.Parse(S);
        int[] n = new int[S.Length];
        for(int i = 0; i < S.Length; i++){
            n[i] = S[i] - '0';
            sum_n += n[i];
        }
        if(N % sum_n == 0){
            WriteLine("Yes");
        }
        else{
            WriteLine("No");
        }
    } 
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int h, w;
	vvi vv;
	char c;
	cin >> h >> w;
	vb vbb(w);
	rep(i, h) {
		vi v;
		bool b=false;
		rep(j, w) {
			cin >> c;
			if (c == '#') {
				b = true;
				v.push_back(1);
				vbb[j] = true;
			}
			else v.push_back(0);
		}
		if (b)vv.push_back(v);
	}
	rep(i,vv.size()) {
		rep(j, w) {
			if(vbb[j])cout << (vv[i][j] == 1 ? "#" : ".");
		}
		cout << endl;
	}
	
}


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

#ifndef DEBUG
#define dump(...)
#endif

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int a, b, ab, need_a, need_b;
    std::cin >> a >> b >> ab >> need_a >> need_b;

    int value1 = (2 * ab) * std::max(need_a, need_b);

    int value2 = a * need_a + b * need_b;

    int value3 = (2 * ab);
    if (need_a < need_b) {
        value3 *= need_a;
        need_b -= need_a;
        value3 += b * need_b;
    } else {
        value3 *= need_b;
        need_a -= need_b;
        value3 += a * need_a;
    }


    dump(value1, value2, value3);
    std::cout << std::min({value1, value2, value3}) << "\n";

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	x := len(s)
	for i := 0; i < x; i++ {
		if s[0:x] == t[0:x] {
			fmt.Println("Yes")
			return
		}
		s = s[x-1:x] + s
	}
	fmt.Println("No")
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

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

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

int main(void){
    int N; cin >> N;
    vector<double> A(N); REP(i,N) cin >> A[i];
    double ans = 0; REP(i,N) ans += 1/A[i];
    ans = 1/ans;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
H,W,M=map(int,input().split())
hl=[]
wl=[]
hwl=set()
for _ in range(M):
    h,w=map(int,input().split())
    hl.append(h)
    wl.append(w)
    hwl.add((h,w))
hl=Counter(hl).most_common()
wl=Counter(wl).most_common()
hm=hl[0][1]
wm=wl[0][1]
for h,hc in hl:
    if hc<hm:
        break
    for w,wc in wl:
        if wc<wm:
            break
        if (h,w) not in hwl:
            print(hm+wm)
            exit()
print(hm+wm-1)

Measured memory_bytes: 121860
import java.io._
import scala.io.StdIn.{readInt, readLine}

object Main {
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0
  class Node(var key:Int, var left:Node = null, var right:Node = null) { }

  def getNodeToInsert(node:Node,keyNode:Node):Node =
    if(node.key > keyNode.key) {
      if(node.left == null) node
      else getNodeToInsert(node.left,keyNode)
    } else {
      if(node.right == null) node
      else getNodeToInsert(node.right,keyNode)
    }

  def insert(tree:Node, keyNode:Node) = {
    val target = getNodeToInsert(tree,keyNode)
    if(keyNode.key < target.key) target.left = keyNode
    else target.right = keyNode
  }

  def inOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      inOrder(tree.left)
      out.write(" ")
      out.write(tree.key.toString)
      if(count<1000) count += 1
      else {
        out.flush
        count = 0
      }
      inOrder(tree.right)
    }

  def preOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      out.write(" ")
      out.write(tree.key.toString)
      if(count<1000) count += 1
      else {
        out.flush
        count = 0
      }
      preOrder(tree.left)
      preOrder(tree.right)
    }

  def main(args:Array[String]) = {
    val n = readInt
    val tree = new Node(-1)

    for(i<-0 until n) {
      val s = readLine.split(" ")
      s(0) match {
        case "insert" =>
          if(tree.key == -1) tree.key = s(1).toInt
          else insert(tree, new Node(s(1).toInt))
        case _ => {
          inOrder(tree)
          out.write("\n")
          out.flush()
          preOrder(tree)
          out.write("\n")
          out.flush()
        }
      }
    }
  }
}

Measured memory_bytes: 302756
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        long ans = 1;
        for (int i = 1; i <= n; i++)
        {
            ans = ans * i % mod;
        }

        CWL(ans);
    }
}

public static partial class Program
{
    //テンプレここから
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static string RL() => ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static void WL(object obj) => WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);

    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    //テンプレここまで
}

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

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
using ll = long long;

const int maxn = 2e5 + 10; 
const int INF = 0x3f3f3f3f;

char s[15];

int main()
{
	fastIO;
	int n,m;
	cin >> n >> m;
	s[1] = s[2] = s[3] = '.';
	for(int i = 0; i < m; ++i) {
		int x; char c;
		cin >> x >> c;
		if(s[x] == '.') s[x] = c;
		else {
			if(s[x] != c) {
				puts("-1");
				return 0;
			}
		}
	}
	if(s[1] == '0' && n > 1) {
		puts("-1");
		return 0;
	}
	for(int i = 1; i <= n; ++i) {
		if(s[i] == '.') {
			if(i == 1) {
				if(n == 1) s[1] = '0';
				else s[1] = '1';
			}
			else s[i] = '0';
		}
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
a = input()
msg1 = "@"
msg2 = "#"
countmsg1 = 0
countmsg2 = 0
flag = 0
for strliteral in a:
    if strliteral == msg1:
        countmsg1 += 1
    elif strliteral == msg2:
        countmsg2 += 1
    else:
        if msg1 == "@":
            msg1 = strliteral
            countmsg1 += 1
        else:
            if msg2 == "#":
                msg2 = strliteral
                countmsg2 += 1
if countmsg2 == 2 and countmsg2 == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

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

    let mut ans = 0;
    for i in 0..n {
        ans += a[i];
    }

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

}


Measured memory_bytes: 2224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3644
from itertools import combinations, product


def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)


def get(fmt):
    ps = input().split()
    r = []
    for p, t in zip(ps, fmt):
        if t == "i":
            r.append(int(p))
        if t == "f":
            r.append(float(p))
        if t == "s":
            r.append(p)
    if len(r) == 1:
        r = r[0]
    return r

def put(*args, **kwargs):
    print(*args, **kwargs)


def rep(n, f, *args, **kwargs):
    return [f(*args, **kwargs) for _ in range(n)]
    
def rep_im(n, v):
    return rep(n, lambda: v)
    
YES_NO = ["NO", "YES"]


a, b, h = rep(3, get, "i")

put((a + b) * h // 2)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> A(N);
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
    if (A[i] < 0) ++cnt;
  }

  LL sum = 0;
  LL min_v = INT_MAX;
  for (LL v : A) {
    v = std::abs(v);
    sum = sum + v;
    min_v = std::min(min_v, v);
  }

  if (cnt % 2 == 0) std::cout << sum << std::endl;
  else              std::cout << sum - 2*min_v << std::endl;
}


Measured memory_bytes: 640
k = int(input())
n = 3
mod = 10**9+7
dp = [0]*(k+1)
ans = 0
for i in range(1, k+1)[::-1]:
    res = pow(k//i, n, mod)
    for j in range(i*2, k+1, i):
        res-=dp[j]
    dp[i] = res%mod
    ans+=i*res
    ans%=mod
print(ans)

Measured memory_bytes: 62104
import sys
x=int(input())
if x==2:
  print(2)
  sys.exit()
for i in range(x,10**5+4):
  for j in range(2,round(i**0.5)+1):
    if i%j==0:
      break
    if j==round(i**0.5) and i%j!=0:
      print(i)
      sys.exit()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
string f(int a,int b)
{
	if(a==b) return "Draw";
	if(a==1) return "Alice";
	if(b==1) return "Bob";
	if(a<b) return "Bob";
	return "Alice";
}
int main()
{
	ios::sync_with_stdio(false);
	int a,b;
	a=read();
	b=read();
	cout<<f(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())

#if N>81:
#  print("No")
#else:
#  for i in range(2,N):
#    if N%i==0:
#      print("Yes")
#      break

listt=[]
for i in range(10):
  for j in range(10):
    listt.append(i*j)
    
if N in listt:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    char dif = 'A' - 'a'; 
    printf("%c%c%c\n",a[0]+dif,b[0]+dif,c[0]+dif);
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("29");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("72");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("91");
            //Yes
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string N = InputList[0];

        Console.WriteLine(N.Contains("9") ? "Yes" : "No");
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int b, f, r, v;;
	int house[5][4][11];
	int i, n;

	for (b = 1; b <= 4; b++) {
		for (f = 1; f <= 3; f++) {
			for (r = 1; r <= 10; r++) house[b][f][r] = 0;
		}
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d%d%d", &b, &f, &r, &v);
		house[b][f][r] += v;
	}

	for (b = 1; b <= 4; b++) {
		for (f = 1; f <= 3; f++) {
			for (r = 1; r <= 10; r++) printf(" %d", house[b][f][r]);
			putchar('\n');
		}
		if (b < 4) puts("####################");
	}
	return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

class Item {
public:
    long long v, w, m;
    explicit Item(long long v, long long w, long long m) : v(v), w(w), m(m) {}
    bool operator < (const Item& it) const { return v * it.w < it.v * w; }
};

int main(){
    int N, W;
    while(cin >> N >> W){
        vector<long long> dp(50*50*N+1, W+1);
        dp[0] = 0;
        vector<Item> vi;
        for(int i=0;i<N;i++){
            long long v, w, m; cin >> v >> w >> m;
            if(m > 50) vi.emplace_back(v, w, m-50);
            m = min(50LL, m);
            for(int j=0;j<v;j++){
                deque<pair<long long, long long>> qu; qu.emplace_back(dp[j], 0);
                for(int k=1;j+k*v<dp.size();k++){
                    auto cur = dp[j+k*v] - k*w;
                    dp[j+k*v] = min(dp[j+k*v], qu.front().first + k * w);
                    while(!qu.empty() && k - qu.front().second >= m) qu.pop_front();
                    while(!qu.empty() && qu.back().first >= cur) qu.pop_back();
                    qu.emplace_back(cur, k);
                }
            }
        }
        sort(vi.rbegin(), vi.rend());
        long long res = 0;
        for(int i=0;i<dp.size();i++){
            if(dp[i] > W) continue;
            long long curV = i;
            long long curW = dp[i];
            for(auto& it : vi){
                auto r = min(it.m, (W-curW)/it.w);
                curV += r * it.v;
                curW += r * it.w;
            }
            res = max(res, curV);
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< int > a(n); std::cin >> a;
  std::sort(all(a));
  auto ret = 0LL;
  rep(i, 0, n) rep(j, i + 1, n) {
    auto x = a.at(i), y = a.at(j);
    int min = std::abs(x - y) + 1;
    int max = x + y - 1;
    if (min > max) continue;
    auto z = std::upper_bound(all(a), max)
      - std::lower_bound(all(a), min);
    z -= min <= x && x <= max;
    z -= min <= y && y <= max;
    ret += z;
  }
  assert(ret % 3 == 0);
  ret /= 3;
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

signed main() {
	int n, k; cin >> n >> k;
	int lb = 0, ub = k + 1;
	while (ub - lb > 1) {
		int mi = (ub + lb) / 2;
		int now = mi, sum = mi;
		int per = 1;
		while (per < n&&now) {
			sum += now / 2;
			now /= 2;
			per++;
		}
		if (sum <= k)lb = mi;
		else ub = mi;
	}
	cout << lb << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n, k, s;
  cin >> n >> k >> s;
  for (ll i = 0; i < k; i++) {
    cout << s << ' ';
  }
  for (ll i = 0; i < n-k; i++) {
    if (s == 1000000000) {
      cout << 1 << ' ';
    }
    else {
      cout << 1000000000 << ' ';
    }
  }
  cout << '\n';
}

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

int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    int xo=0;
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        xo^=a[i];
    }
    for(int i=0;i<n;i++){
        printf("%d ",(xo^a[i]));
    }
    return 0;
}

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


int main()
{
   
   
    long long int n;
    cin>>n;
    long long int a[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long int ans=a[n-1];
    long long int j=n-2;
    long long int c=0;
    for(long long int i=n-3;i>=0;i--)
    {
        if(c==2)
        {
            j-=1;
            c=0;
        }
        ans+=a[j];
        c+=1;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
int main()
{
	ll n, k;
	cin >> n >> k;
	ll h[n + 1], dp[n + 1] = {0};
	for(ll i = 1; i <= n; i++) cin >> h[i];

	dp[n] = 0;
	for(ll i = n - 1; i; i--)
	{
		ll m = 9999999999999;
		for(ll j = 1; j <= min(k, n - i); j++)
		{
			m = min(m, dp[i + j] + abs(h[i] - h[i + j]));
		}
		dp[i] = m;
	}
	cout << dp[1];
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <numeric>
#include <cmath>

using namespace std;
using sl = signed long;
using sll = signed long long;
using ll = long long;

// For debug
template <class T> void print_vecotor(vector<T> v){
	for(auto itr=v.begin();itr<v.end();itr++){
		cout << *itr << " ";
	}
}

int main(int argc, char *argv[])
{
	int A, B;
	cin >> A >> B;

	auto ans = A - 2*B;
	if(ans <0) ans = 0;
	
	cout << ans;
	return 0;
}

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

Measured memory_bytes: 256
import Data.Functor( (<$>))

main = do
    n <- read <$> getLine
    problem <- (read <$>) . words <$> getLine	::IO [Int]
    let
	merge [] x = [x]
	merge list@(a:as) x
	    | x<=a	= x:list
	    | otherwise	= a:merge as x

	step result@(list, [])  = result
	step (list1, e:es) = (merge list1 e, es)

	display (list1, list2) = putListLn $ list1++list2
	  where
	    putListLn = putStrLn . unwords . (show <$>)

    display `mapM_` (take n . tail $ iterate step ([],problem))



Measured memory_bytes: 4148
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <numeric>

using namespace std;

typedef long long ll;

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


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

int main()
{
    int A, B, C, X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;

    int ans = 0;
    for(int a = 0; a <= A && a*500 <= X; a++) {
        int x1 = X - a*500;
        for(int b = 0; b <= B && b*100 <= x1; b++) {
            int x2 = x1 - b*100;

            if(x2 / 50 <= C) 
                ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

class Node{
public:
    int location;
    int p, l, r;
    Node(){}
};

class Point {
public:
    int id, x, y;
    Point(){}
    Point(int id, int x, int y): id(id), x(x), y(y) {}
    bool operator < (const Point &p) const {
        return id < p.id;
    }

    void print(){
        printf("%d\n", id);
    }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

int makeKDTree(int l, int r, int depth){
    if( !(l < r) ) return NIL;
    int mid = (l + r) / 2;
    int t = np++;
    if(depth % 2 == 0){
        sort(P + l, P + r, lessX); //Pはclass Point の配列，関数lessXを指定してxの昇順でソート
    }else{
        sort(P + l, P + r, lessY); //奇数層はyでソートし直し
    }
    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth + 1);
    T[t].r = makeKDTree(mid + 1, r, depth + 1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans){
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if( sx <= x && x <= tx && sy <= y && y <= ty ){
        ans.push_back(P[T[v].location]);
    }

    if( depth % 2 == 0){
        if( T[v].l != NIL ){
            if( sx <= x ) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
        }
        if( T[v].r != NIL ){
            if( x <= tx ) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
        }
    }else{
        if( T[v].l != NIL ){
            if( sy <= y ) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
        }
        if( T[v].r != NIL ){
            if( y <= ty ) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
        }
    }
}

int main() {
    int x, y;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }

    np = 0;

    int root = makeKDTree(0, N, 0);

    int q;
    scanf("%d", &q);
    int sx, tx, sy, ty;
    vector<Point> ans;
    for(int i = 0; i < q; i++){
        scanf("%d %d %d %d", &sx, &tx, & sy, &ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for(int j = 0; j < ans.size(); j++) ans[j].print();
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 15916
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

const int MAX_V = 100010;

vector<vector<int>> G(MAX_V);
vector<pair<int, int>> bridge;
vector<int> articulation;
int ord[MAX_V], low[MAX_V];
bool visited[MAX_V];

void dfs(int cv, int pv, int &k){
    visited[cv] = true;

    ord[cv] = k++;
    low[cv] = ord[cv];

    bool isArticulation = false;
    int cnt = 0;

    for(int i=0; i<G[cv].size(); i++){
        int nv = G[cv][i];

        if(!visited[nv]){
            cnt++;
            dfs(nv, cv, k);
            low[cv] = min(low[cv], low[nv]);
            if(~pv && ord[cv] <= low[nv]) isArticulation = true;
            if(ord[cv] < low[nv]) bridge.emplace_back(minmax(cv, nv));
        }
        else if(nv != pv){
            low[cv] = min(low[cv], ord[nv]);
        }
    }

    if(pv == -1 && 1 < cnt) isArticulation = true;
    if(isArticulation) articulation.emplace_back(cv);
}

int main(){
    int n, m; cin>>n>>m;
    for(int i=0; i<m; i++){
        int s, t; cin>>s>>t;
        G[s].emplace_back(t);
        G[t].emplace_back(s);
    }

    int k = 0;
    for(int i=0; i<n; i++){
        if(!visited[i]) dfs(i, -1, k);
    }

    sort(articulation.begin(), articulation.end());
    sort(bridge.begin(), bridge.end());

    for(auto i:articulation){
        cout << i << endl;
    }
    /*
    for(auto i:bridge){
        cout << i.first << " " << i.second << endl;
    }
    */
}


Measured memory_bytes: 6616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

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

	
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int A[17],f[1<<16|1];
int fact[1<<16|1],ifact[1<<16|1];
int C(int n,int m){if(n<0||m<0||n<m)return 0;return 1ll*fact[n]*ifact[m]%mod*ifact[n-m]%mod;}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int g=gi(),n=1<<g,m=gi();
	fact[0]=1;for(int i=1;i<=n;++i)fact[i]=1ll*fact[i-1]*i%mod;
	ifact[n]=pow(fact[n],mod-2);for(int i=n;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
	for(int i=0;i<m;++i)A[i]=gi();
	f[0]=1;
	for(int i=m-1;~i;--i){
		for(int S=n-1;~S;--S)
			for(int T=0;T<g;++T)
				if(~S>>T&1)
					inc(f[S|(1<<T)],1ll*f[S]*C(n-A[i]-S,(1<<T)-1)%mod*fact[1<<T]%mod);
	}
	int ans=0;
	for(int S=0;S<n;++S){
		int sum=n-S-1,res=f[S];
		for(int i=0;i<g;++i)if(sum>>i&1)res=1ll*res*C(sum,1<<i)%mod*fact[1<<i]%mod,sum-=(1<<i);
		assert(!sum);
		(__builtin_parity(S)?dec(ans,res):inc(ans,res));
	}
	printf("%d\n",1ll*n*ans%mod);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  string a[H];
  string b[2*H];
  for(int i = 0; i < H; ++i){
      cin >> a[i];
      b[2*i] = a[i];
      b[2*i+1] = a[i];
  }
  for(int i = 0; i < 2*H; ++i){
    cout << b[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	int s,w;
	cin>>s>>w;
	if (s>w)
	cout<<"safe";
	else
	cout<<"unsafe";	
	return 0;
}













Measured memory_bytes: 3652
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
from functools import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

# python3.4では存在しない!!
# from math import gcd

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

N, X = map(int, input().split())
Xs = map(int, input().split())
diffs = [abs(X - x) for x in Xs]
ans = reduce(gcd, diffs)
print(ans)



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
typedef ll i1;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<P> items;
    rep(i, N - 1) {
        ll u, v;
        cin >> u >> v;
        if (v > u) swap(u, v);
        items.push_back({u, v});
    }
    ll ans = 0;
    rep2(i, 1, N + 1) {
        ans += i * (N - i + 1);
    }
    rep(i, N - 1) {
        ll u = items[i].first;
        ll v = items[i].second;
        ans -= v * (N - u + 1);
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 7416
S = input()

keyence = 'keyence'

ans = 'NO'
if S[0] != 'k':
    if S[-7:] == keyence:
        ans = 'YES'

for i in range(7):
    if S[:i] == keyence[:i]:
        if S[i-7:] == keyence[i-7:]:
            ans = 'YES'

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

vector<string> weathers = {"Sunny", "Cloudy", "Rainy"};

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

	int idx;
	if (s == weathers[0]) {
		idx = 0;
	} else if (s == weathers[1]) {
		idx = 1;
	} else {
		idx = 2;
	}

	string ans = weathers[(idx + 1) % 3];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.split.map(&:to_i)
cnt = 0
max = 0
for i in 0..(n-2)
    if h[i] >= h[i+1]
        cnt += 1
    else 
        if cnt > max 
            max = cnt
        end
        cnt = 0
    end 
end
if cnt > max 
    max = cnt
end
puts max

Measured memory_bytes: 8580
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 31 13:26:37 2018
//
package main

import "fmt"

func main() {
	arr := make([][]int, 3)
	for i := range arr {
		arr[i] = make([]int, 3)
		for j := range arr[i] {
			fmt.Scan(&arr[i][j])
		}
	}

	t1 := arr[0][1] - arr[0][0]
	t2 := arr[0][2] - arr[0][1]
	s1 := arr[1][0] - arr[0][0]
	s2 := arr[2][0] - arr[1][0]
	for i := range arr {
		if arr[i][1]-arr[i][0] != t1 || arr[i][2]-arr[i][1] != t2 {
			fmt.Println("No")
			return
		}
		if arr[1][i]-arr[0][i] != s1 || arr[2][i]-arr[1][i] != s2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include "bits/stdc++.h"
using namespace std;
#define int long long

int32_t main(){
    string s, t;
    cin >> s >> t;
    int ans = INT_MAX;
    for( int i = 0; i <= s.size()-t.size(); i++ ){
        int cnt = 0;
        for( int j = 0, k = i; j < t.size(); j++, k++ ){
            if( t[j] != s[k] )cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c,d;cin >> a >> b >> c >> d;
    if(abs(c-a) <= d || (abs(b-a)<=d && abs(c-b)<=d)) cout << "Yes" << endl;
    else cout << "No" << endl;
        
    return 0;
}

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

int main(){
  string S;
  cin>>S;
  if(S.length()==2){
    cout<<S<<endl;
    return 0;
  }
  cout<<S.at(2)<<S.at(1)<<S.at(0)<<endl;
  return 0;
}


Measured memory_bytes: 3628
#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;

int main() {
    int h,w; cin >> h >> w;
    vector<vector<char>> a(h,vector<char> (w));
    bool t[h] = {false};
    bool y[w] = {false};
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
            if(a[i][j] == '#'){
                t[i] = true;
                y[j] = true;
            }
        }
    }
    rep(i,h){
        if(t[i]){
            rep(j,w){
                if(y[j]){
                    cout << a[i][j];
                }
            }
        }else{
            continue;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
vi wrzut;
map<int,int>cnt;
int32_t main()
{
  BOOST;
	int ans=0;	
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		int a;
		cin>>a;
		cnt[a]++;
	}
	for (auto it:cnt){
		if (it.nd>=4)ans=max(ans,it.st*it.st);
		if (it.nd>=2)wrzut.pb(it.st);
	}
	sort(wrzut.begin(),wrzut.end());
	if (sz(wrzut)>=2){
		int m=sz(wrzut);
		ans=max(ans,wrzut[m-1]*wrzut[m-2]);
	}
	cout<<ans;
  return 0;
}


Measured memory_bytes: 9720
#include <stdio.h>
int a[101][101];

int main(void) {
    int r,c;
    scanf( "%d %d", &r, &c );
    for( int i=0; i<r; i++ ){
        for( int j=0; j<c; j++ ){
            scanf( "%d", &a[i][j] );
            a[i][c]+=a[i][j];
            a[r][j]+=a[i][j];
            a[r][c]+=a[i][j];
        }
    }
    for( int i=0; i<=r; i++ ){
        for( int j=0; j<=c; j++ ){
            if( j ) printf( " " );
            printf( "%d", a[i][j] );
        }
        printf( "\n" );
    }
    return 0;
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18;

signed main(){
	int N;
	cin>>N;
	int ans = INF;
	for(int i = 1;i*i <=N;i++){
		if(N%i)continue;
		int ni = N/i;
		CHMIN(ans,i-1+ni-1);
	}
	cout<<ans<<endl;
}

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

// The choice that will maximize Taro's happiness is given by the 2D recurrence A(n, a),
// where n is the current day and a is the activity performed on day n.
//
// A(n, a) = (max_{b != a} A(n-1, b)) + a_n

int max(int a, int b)
{
    return a > b ? a : b;
}

int max3(int a, int b, int c)
{
    return max(max(a, b), c);
}

int solution(int **arr, int n)
{
    int **memo = (int **)malloc(sizeof(int *)*n);
    int i, j;
    
    for (i = 0; i < n; i++)
    {
        int *row = (int *)malloc(sizeof(int)*3);
        memo[i] = row;
    }
    
    memo[0][0] = arr[0][0];
    memo[0][1] = arr[0][1];
    memo[0][2] = arr[0][2];
    
    for (i = 1; i < n; i++)
    {
        int act0 = memo[i-1][0];
        int act1 = memo[i-1][1];
        int act2 = memo[i-1][2];
        memo[i][0] = max(act1, act2) + arr[i][0];
        memo[i][1] = max(act0, act2) + arr[i][1];
        memo[i][2] = max(act0, act1) + arr[i][2];
    }
    
    int act0 = memo[n-1][0];
    int act1 = memo[n-1][1];
    int act2 = memo[n-1][2];
    
    return max3(act0, act1, act2);
}

int main(int argc, char **argv)
{
    int n;
    scanf("%d", &n);
  
    int **arr = (int **)malloc(sizeof(int *)*n);
    int i, j;
    for (i = 0; i < n; i++)
    {
        int *row = (int *)malloc(sizeof(int *)*3);
        for (j = 0; j < 3; j++)
        {
            scanf("%d", row+j);
        }
        arr[i] = row;
    }
    int best = solution(arr, n);
    printf("%d\n", best);
}

Measured memory_bytes: 7936
package main

import (
	"strconv"
	"bufio"
	"os"
	"strings"
	"fmt"
)

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_B>
 */

func init() {

}

func main() {
	v, _ := SplitIntStdin(" ")
	if v[0] < v[1] && v[1] < v[2]{
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}

// ????????????1?????????
func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput := scanner.Text()

	stringReturned = strings.TrimSpace(stringInput)
	return
}

// ??´??°???1?????????
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

// ?????????????????????????????????????????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}

	return
}

// ??????????????§??????????????????????????????????????????
func SplitStrStdin(delim string) (stringReturned []string) {
	// ???????????§1?????????
	stringInput := StrStdin()

	// ????????§??????
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// ??????????????§??????????????´??°????????????????????????
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// ??????????????????????????????
	stringSplited := SplitStrStdin(" ")

	// ??´??°?????????????????????
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

Measured memory_bytes: 1096
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <cstdlib>
#include <iostream>
using namespace std;
int a, b, c, x, n = 0;
char buffer [100000] = {0};
bool kaibun(int k){
    string s = to_string(k);
    for(int j=0; j<=s.size()/2; j++){
        if(s[j]!=s[s.size()-j-1]){
            return(false);
        }
    }
    return(true);
}
int main()
{
    cin>>a>>b;
    for(int i=a; i<=b; i++){
        if(kaibun(i)==true)
            c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,ans=0;
	cin >> n;
	int s[n+1];
	for(int i=1;i<=n;i++){
		cin >> s[i];
	}
	do{
		int f=0;
		for(int i=1;i<=n;i++){
			if(s[i]%2){
				f=1;
				break;
			}else{
				s[i]/=2;
			}
		}
		if(f){
			break;
		}
	}while(++ans);
	cout << ans;
}

Measured memory_bytes: 256