akhauriyash/Code-Regression huggingface dataset:
import sys


def solv(hand):
    if four_card(hand):
        return "four card"
    elif full_house(hand):
        return "full house"
    elif straight(hand):
        return "straight"
    elif three_card(hand):
        return "three card"
    elif two_pair(hand):
        return "two pair"
    elif one_pair(hand):
        return "one pair"
    else:
        return "null"

def four_card(hand):
    s = set(hand)
    if len(s) == 2:
        for c in s:
            if count(hand, c) == 4:
                return True
    else:
        return False

def full_house(hand):
    s = set(hand)
    if len(s) == 2:
        for c in s:
            if count(hand, c) == 3:
                return True
    else:
        return False

def straight(hand):
    hand.sort()
    if difference_one(hand):
        return True
    elif difference_one(change_ace(hand)):
        return True
    else:
        return False

def three_card(hand):
    s = set(hand)
    if len(s) == 3:
        for c in s:
            if count(hand, c) == 3:
                return True
    else:
        return False

def two_pair(hand):
    s = set(hand)
    return len(s) == 3

def one_pair(hand):
    s = set(hand)
    return len(s) == 4


def count(hand, c):
    return len(filter(lambda x: x == c, hand))

def difference_one(hand):
    r = []
    d = reduce(lambda x, y: (add_list(x[0], y-x[1]), y), hand, (r,0))
    d[0].pop(0)
    return d[0] == [1,1,1,1]

def add_list(lis, x):
    lis.append(x)
    return lis

def change_ace(hand):
    r = []
    for c in hand:
        if c == 1:
            r.append(14)
        else:
            r.append(c)
    r.sort()
    return r



for line in sys.stdin:
    hand = map(int, line.split(','))
    print solv(hand)

Measured memory_bytes: 4372
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long A = sc.nextLong();
    long B = sc.nextLong();
    long x = N / (A + B);
    long y = N % (A + B);
    System.out.println(x * A + Math.min(y, A));
  }
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define INF 1000000000

int n, k, h[100001], memo[100001];

int FROG2(int i)
{
	if(i == n)
	return 0;
	if(memo[i] != -1)
	return memo[i];	
	int ans = INF;
	for(int j=1;j<=k;j++)
	{
		if(i+j <= n)
		ans = std::min(ans, abs(h[i] - h[i+j]) + FROG2(i+j));	
	}	
	memo[i] = ans;
	return ans;	
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	std::cin>>n>>k;
	for(int i=1;i<=n;i++)
	std::cin>>h[i];
	int ans = FROG2(1);
	std::cout<<ans<<"\n";
	return 0;
}

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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] nums = {"0","0"};
      int[] matChain = new int[n+1];

      for(int i=0; i<n; i++) {
        nums = br.readLine().split(" ");
        matChain[i] = Integer.parseInt(nums[0]);
      }
      matChain[n] = Integer.parseInt(nums[1]);


      System.out.println( matrixChainMultiplication(matChain) );
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }

  private int matrixChainMultiplication(int[] p) {
    int n = p.length-1;
    int[][] m = new int[n+1][n+1];
    for(int i=1; i<=n; i++) {
      m[i][i] = 0;
    }

    for(int l=2; l<=n; l++) {
      for(int i=1,j=0; i<=n-l+1; i++) {
        j = i+l-1;
        m[i][j] = Integer.MAX_VALUE;
        for(int k=i,c=0; k<=j-1; k++) {
          c = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
          m[i][j] = m[i][j] < c ? m[i][j] : c;
        }
      }
    }

    return m[1][n];
  } 
}


Measured memory_bytes: 24428
n = int(input())
a = [[[0] * 10 for i in range(3)] for j in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    a[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        l = a[i][j]
        print(' ' + ' '.join(map(str, l)))
    if i < 3:
        print("#"*20)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}

int main() {
  ll w,h,x,y;cin>>w>>h>>x>>y;
  int ans;
  double s=w*h/2.0;
  cout<<s<<" ";
  if((x*2==w)&&(y*2==h)){
    ans=1;
  }else{
    ans=0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define endl "\n"
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  ll ans = 0;
  set<pair<ll,ll> > se;
  rep(i,1,1000001){
    ll a = i;
    ll b = n-i;
    if(b>0&&a!=b){
      se.insert(mp(min(a,b),max(a,b)));
    }
  }
  cout << se.sz << endl;
  return 0;
}

Measured memory_bytes: 31488
using System;
using System.IO;
using System.Linq;

namespace Contest
{
    class Program
    {
        private Scanner sc;
        public void Solve()
        {
            sc = new Scanner();
            int[] ar = sc.IntArray();
            Console.WriteLine(ar.Sum() - ar.Max());


        }


        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N, R;
    cin >> N >> R;
    if (N >= 10) cout << R << endl;
    else cout << R + 100 * (10 - N) << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Data.Bits
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Data.Coerce

main :: IO ()
main = do
  str <- getLine
  let ls = zipWith3 (\x y z -> read [x,y,z]) str (tail str) (tail $ tail str)
  putStrLn $ show $ minimum $ map (abs . subtract (753 :: Int)) ls

Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<bitset>
using namespace std;

int main(){

    int a[3];
    cin >> a[0] >> a[1] >>a[2];
    sort(a,a+3);

    cout << a[0]+a[1]  <<endl;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def print_sw(a):
    for i in a[:-1]:
        if i == '0':
            print('S',end = '')
        else:
            print('W', end = '')

def solve():
    n = f()[0]
    s = input()

    for i in [ 0, 1]:
        for j in [0, 1]:
            a = str(i) + str(j)
            for k in range(2, n+1):
                if a[k-1] == '0':
                    if s[k-1] == 'o':
                        a += a[k-2]
                    else:
                        a += str(int(a[k-2])^1)
                else:
                    if s[k-1] == 'x':
                        a += a[k-2]
                    else:
                        a += str(int(a[k-2])^1)

            if a[0] != a[n]:
                continue
            
            if a[0] == '0':
                if a[1] == a[n-1] and s[0] == 'o':
                    print_sw(a)
                    return
                elif a[1] != a[n-1] and s[0] == 'x':
                    print_sw(a)
                    return
            else:
                if a[1] == a[n-1] and s[0] == 'x':
                    print_sw(a)
                    return
                elif a[1]!=a[n-1] and s[0] == 'o':
                    print_sw(a)
                    return
    
    print(-1)


solve()


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

int main() {
    double r;
    double area, circum;
    cin >> r;
    area = M_PI * pow(r, 2.0);
    circum = 2.0 * M_PI * r;
    cout << fixed << setprecision(6) << area << " " << circum << endl;
    return 0;
}



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

struct rmq{
    int n; //size
    vector<int> segtree; //完全二分木を格納した配列
    const int INF = INT_MAX;
    
    rmq(int sz){
    	n = 1;
        while(n<sz) n<<=1; //配列サイズをsz以上の2冪に。
        //セグ木のサイズは2*n-1, 取り敢えず全て単位元で初期化しておく。
        segtree.assign(2*n-1,INF);
    }
    
    int find(int l, int r){
    	return find(l,r,0,n,0);
    }
    int find(int l, int r, int a, int b, int k){
    	if(b<=l || r<=a) return INF;  //区間外
        else if(l<=a && b<=r) return segtree[k];  //区間内
        //それ以外なら、子を調べてその結果をminしたものを返す。
        else return min(find(l,r,a,(a+b)/2,2*k+1), find(l,r,(a+b)/2,b,2*k+2));
    }
    void update(int i, int x){
        i += n-1;
        segtree[i] = x; //元の配列のindexは頂点数2*n-1より、n-1足したもの。
        while(i>0){
            i = (i-1)/2;  //親に移動
            //子同士を比較して小さい方を親の値として更新。
            segtree[i] = min(segtree[2*i+1],segtree[2*i+2]);
        }
    }
};

int main(){
	int n, q;
	cin >> n >> q;
    rmq tr(n);
    for(int i=0; i<q; i++){
        int com, x, y;
        cin >> com >> x >> y;
        if(com==0){
            tr.update(x,y);
        }else{
            cout << tr.find(x,y+1) << endl;
        }
    }
}


Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#define rep(i, n) for (int i = 0; i < n; i++) 
using namespace std;

int main() {
    long double l;
    cin >> l;
    cout << std::fixed << std::setprecision(8) << pow(l/3, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int x, k;
    cin >> x >> k;
    struct query {int t, a;};
    vector<query> qs;
    
    repeat(i, k) {
        query q;
        cin >> q.t;
        q.a = -1;
        qs.emplace_back(q);
    }
    
    int q;
    cin >> q;
    repeat(i, q) {
        query q;
        cin >> q.t >> q.a;
        qs.emplace_back(q);
    }
    
    sort(qs.begin(), qs.end(), [](const query q1, const query q2) {return q1.t < q2.t;});
    
    struct phase {int a, b, c, t;};
    phase line;
    line.a = 0; line.b = x; line.c = 0; line.t = 0;
    
    const int UP = 1;
    const int DOWN = -1;
    auto next_phase = [&](phase line, int dir, int t) -> phase {
        int a = line.a;
        int b = line.b;
        int c = line.c;
        int d = t - line.t;
        
        phase ret_line = line;
        ret_line.t = t;
        
        if (dir == DOWN) {
            if (d <= a) {
                ret_line.a = a - d;
                ret_line.b = b - d;
                ret_line.c = c - d;
            }
            else if (a < d && d <= b) {
                ret_line.a = 0;
                ret_line.b = b - d;
                ret_line.c = c - d;
            }
            else {
                ret_line.a = 0;
                ret_line.b = 0;
                ret_line.c = 0;
            }
        }
        else if (dir == UP) {
            if (d <= x - b) {
                ret_line.a = a + d;
                ret_line.b = b + d;
                ret_line.c = c + d;
            }
            else if (x - b < d && d <= x - a) {
                ret_line.a = a + d;
                ret_line.b = x;
                ret_line.c = c + d;
            }
            else {
                ret_line.a = x;
                ret_line.b = x;
                ret_line.c = x;
            }
        }
        return ret_line;
    };
    
    auto get_sand = [&](phase line, int x) -> int {
        int a = line.a;
        int b = line.b;
        int c = line.c;
        int ret;
        if (x <= a - c) {
            ret = a;
        }
        else if (a - c < x && x <= b - c) {
            ret = c + x;
        }
        else {
            ret = b;
        }
        return ret;
    };
    
    int dir = DOWN;
    for (query q: qs) {
        if (q.a < 0) {
            line = next_phase(line, dir, q.t);
            dir = -dir;
        }
        else {
            line = next_phase(line, dir, q.t);
            cout << get_sand(line, q.a) << endl;
        }
    }
}

Measured memory_bytes: 2928
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int n = nextInt();
			int r = nextInt();

			if (n == 0) {
				break;
			}

			int[] p = new int[r];
			int[] c = new int[r];
			for (int i = 0; i < r; i++) {
				p[i] = nextInt() - 1;
				c[i] = nextInt();
			}

			int place = 1;
			for (int i = r - 1; i >= 0; i--) {
				if (place <= c[i]) {
					place += p[i];
				} else if (place > c[i] && place <= p[i] + c[i]) {
					place -= c[i];
				}
			}

			System.out.println(n + 1 - place);

		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 19448
import collections
h,w=map(int,input().split())
a=""
for i in range(h):
    a+=input()
f,o=1,0
for i in collections.Counter(a).values():
    f+=i//4
    o+=i&1
print(["No","Yes"][f>(h//2)*(w//2) and o<=h%2*w%2])

Measured memory_bytes: 3316
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int H, A; cin >> H >> A;
    if (H % A == 0) cout << H / A << endl;
    else cout << H / A + 1 << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import itertools

H, W, K = map(int, input().split())
C = []
for _ in range(H):
    C.append(list(input()))
C = np.array(C)

Hs = []
for i in range(H + 1):
    Hs.extend(list(itertools.combinations(range(H), i)))
Ws = []
for i in range(W + 1):
    Ws.extend(list(itertools.combinations(range(W), i)))

ans = 0
for h_list in Hs:
    for w_list in Ws:
        C_tmp = C.copy()
        for h in h_list:
            for i in range(W):
                C_tmp[h][i] = 'r'

        for w in w_list:
            for i in range(H):
                C_tmp[i][w] = 'r'

        c = 0
        for i in range(H):
            for j in range(W):
                if C_tmp[i][j] == '#':
                    c += 1
        if c == K:
            ans += 1

print(ans)


Measured memory_bytes: 27152
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
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();
}

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

int h, w;
char s[2222][2222];

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

  cin >> h >> w;
  FOR(y, 1, h + 1) FOR(x, 1, w + 1) cin >> s[y][x];

  vector<vector<int>> v1(h + 2, vector<int>(w + 2, 0)),
      v2(h + 2, vector<int>(w + 2, 0));

  FOR(y, 1, h + 1) {
    FOR(x, 1, w + 1) {
      if (s[y][x] == '#') continue;
      v1[y][x] = v1[y][x - 1] + 1;
      v2[y][x] = v2[y - 1][x] + 1;
    }
  }

  for (int y = h; 0 <= y; y--) {
    for (int x = w; 0 <= x; x--) {
      if (s[y][x] == '#') continue;
      v1[y][x] = max(v1[y][x + 1], v1[y][x]);
      v2[y][x] = max(v2[y + 1][x], v2[y][x]);
    }
  }

  int ans = 0;
  FOR(y, 1, h + 1) {
    FOR(x, 1, w + 1) {
      if (s[y][x] == '#') continue;
      ans = max(ans, v1[y][x] + v2[y][x] - 1);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 36096
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
#else 
#endif
}
void fast(){
	std::ios_base::sync_with_stdio(0); cin.tie(NULL);
}
int main()
{
	fast();
	int n;
	cin >> n;
	int mx = 0;
	vector<int>v(n);
	map<int, int>mp;
	for (int i = 0; i < n; i++){
		cin >> v[i];
		mp[v[i]]++;
	}
	for (int i = 0; i < n; i++){

		mx = max(mx, mp[v[i]] + mp[v[i] + 1] + mp[v[i] - 1]);
	}
	cout << mx << endl;
}

Measured memory_bytes: 5120
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();		
      	int N = sc.nextInt();
		int attack_sum = 0;
      	for(int i=0;i<N;i++){
        	attack_sum += sc.nextInt();
        }
      	if(attack_sum>=H){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
		
    }
}

Measured memory_bytes: 49136
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    ll r,D;
    ll x[11];
    cin >> r >> D >> x[0];
    for(ll i = 1; i <= 10; i++){
        x[i] = r * x[i-1] - D;
        cout << x[i] << "\n";
    }
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n,b,f,r,v,college[4][3][10]={0};
  cin>>n;
  for(int m=0;m<n;m++){
  cin>>b>>f>>r>>v;
  college[b-1][f-1][r-1]+=v;
//  if(college[b-1][f-1][r-1]>9)college[b-1][f-1][r-1]=9;
  //if(college[b-1][f-1][r-1]<0)college[b-1][f-1][r-1]=0;
  }
for(int i=0;i<4;i++){
  if(i!=0){
    for(int l=0;l<20;l++)cout<<"#";
    cout<<endl;
  }
    for (int j = 0; j <3 ; j++) {
      for (int k=0;k<10;k++){
        if(college[i][j][k]!=0)cout<<" "<<college[i][j][k];
        else{cout<<" "<<0;}
      }
      cout<<endl;
    }
}
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


void solve(){
	int a, b;
	cin>>a>>b;
	if(a%2 && b%2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
static long gcd(long x, long y) {
    while (y > 0) {
        long r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int main() {
    long x, y;
    std::cin >> x >> y;
    std::cout << gcd(x, y) << std::endl;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int ara[50];

int main()
{
    int n,cnt,i,a;
    scanf("%d",&n);
    cnt=1;
    scanf("%d",&ara[0]);
    a=ara[0];
    for(i=1; i<n; i++)
    {
        scanf("%d",&ara[i]);
        if(ara[i]>=a && ara[i]>=ara[0] && ara[i]>=ara[1])
        {
            cnt++;
            a=ara[i];
        }
    }
    printf("%d",cnt);
    
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

WALL = 100
w, h = map(int,input().split())
lst = [[WALL] + list(map(int,input().split())) + [WALL] for i in range(h)]
lst.insert(0, [WALL] * (w + 2))
lst.append([WALL] * (w + 2))

visited = [[0] * (w + 2) for _ in range(h + 2)]
hold = []

def search(x, y):

  if lst[x][y] == WALL:
    visited[x][y] = 3
    return 3

  if lst[x][y] == 1:
    visited[x][y] = 2
    return 2

  visited[x][y] = 1
  hold.append((x, y))

  if not x % 2:
    pairs = [(x - 1, y - 1), (x - 1, y), (x, y - 1), (x, y + 1), (x + 1, y - 1), (x + 1, y)]
  else:
    pairs = [(x - 1, y), (x - 1, y + 1), (x, y - 1), (x, y + 1), (x + 1, y), (x + 1, y + 1)]
  
  ret = 0
  for t in pairs:
    tx, ty = t[0], t[1]
    a = 0
    if not visited[tx][ty]:
      a = search(tx, ty)
    elif visited[tx][ty] == 3:
      a = 3
    elif visited[tx][ty] == 2:
      a = 2
    if a > ret:
      ret = a

  return ret

for x in range(1, h + 1):
  for y in range(1, w + 1):
    if not visited[x][y] and not lst[x][y]:
      stat = search(x, y)
      for point in hold:
        visited[point[0]][point[1]] = stat
      hold.clear()

ans = 0
for x in range(1, h + 1):
  for y in range(1, w + 1):
    if lst[x][y]:
      if not x % 2:
        pairs = [(x - 1, y - 1), (x - 1, y), (x, y - 1), (x, y + 1), (x + 1, y - 1), (x + 1, y)]
      else:
        pairs = [(x - 1, y), (x - 1, y + 1), (x, y - 1), (x, y + 1), (x + 1, y), (x + 1, y + 1)]
      for t in pairs:
        tx, ty = t[0], t[1]
        if (visited[tx][ty] in [0,3]) and (lst[tx][ty] in [WALL, 0]):
          ans += 1

print(ans)


Measured memory_bytes: 17040
#include<stdio.h>

int main(void){

  char str[1010];

  int i,sum;

  scanf("%s",str);

  while(str[0]!='0'){

  i=0;

  sum=0;

  while(str[i]){

sum+=str[i]-'0';

  i++;

  }

  printf("%d\n",sum);

  scanf("%s",str);

  }
return 0;

}
 

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

int main() {

  int L,M,N,X;
  cin >> X;

  N=X/500;//嬉しさ
  M=X%500;//あまりのお金495とか

  if(M!=0){
    L=M/5;
  }

  cout << N*1000+L*5 << endl;

}



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

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    int ans = 1000000000;

    for (auto i = 0; i < n; i++)
    {
        int wi;
        cin >> wi;
        w[i] = wi;
    }

    for (auto t = 0; t < n-1; t++)
    {
        int s1 = 0, s2 = 0;
        int tmp = 0;

        for (auto i = 0; i < t+1; i++)
        {
            s1 += w[i];
        }

        for (auto i = t+1; i < n; i++)
        {
            s2 += w[i];
        }

        tmp = abs(s1 - s2);
        if(tmp < ans){
            ans = tmp;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[N][N];
int color[N],d[N],f[N],tt;
void dfs_visit(int u){
    int v;
    color[u]=GRAY;
    d[u]=++tt;
    for(v=0;v<n;v++){
        if(M[u][v]==0)continue;
        if(color[v]==WHITE){dfs_visit(v);}
    }
    color[u]=BLACK;
    f[u]=++tt;;
}
void dfs(){
    int u;
    for(u=0;u<n;u++)color[u]=WHITE;
    tt=0;
    for(u=0;u<n;u++){
        if(color[u]==WHITE)dfs_visit(u);
    }
    for(u=0;u<n;u++)printf("%d %d %d\n",u+1,d[u],f[u]);
}
int main(){
    int u,v,k,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++)M[i][j]=0;
    }
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(j=0;j<k;j++){
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }
    dfs();
}

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

class Program
{
	static void Main()
	{
		var nm = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var n = nm[0];
		var m = nm[1];

		var datas = new Dictionary<int, List<int>>();
		for (var i = 0; i < n; ++i) {
			var ab = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
			var a = ab[0];
			var b = ab[1];
			if (datas.ContainsKey(a)) {
				datas[a].Add(b);
			} else {
				datas.Add(a, new List<int>(new[] { b }));
			}
		}

		var queue = new PriorityQueue<int>((item1, item2) => item1.CompareTo(item2));
		var sum = 0;
		for (var i = 1; i <= m; ++i) {
			if (datas.ContainsKey(i)) {
				datas[i].ForEach(data => queue.Enqueue(data));
			}

			if (queue.Any()) {
				sum += queue.Dequeue();
			}
		}

		Console.WriteLine(sum);
	}
}

internal class PriorityQueue<T>
{
	private readonly Comparison<T> comparison_;

	private T[] items_;

	private int count_;

	internal PriorityQueue(Comparison<T> comparison)
	{
		comparison_ = comparison;
		items_ = new T[2];
	}

	internal bool Any()
	{
		return count_ > 0;
	}

	internal void Enqueue(T item)
	{
		if (items_.Length == count_) {
			var tempItems = items_;
			items_ = new T[items_.Length * 2];
			tempItems.CopyTo(items_, 0);
		}

		items_[count_] = item;
		var index = count_;
		while (index > 0) {
			var parentIndex = (index - 1) / 2;
			if (comparison_(item, items_[parentIndex]) > 0) {
				items_[index] = items_[parentIndex];
				index = parentIndex;
			} else {
				break;
			}
		}

		items_[index] = item;
		++count_;
	}

	internal T Dequeue()
	{
		var returnItem = items_[0];
		--count_;

		var lastItem = items_[count_];
		var rootIndex = 0;
		var childIndex = 1;
		while (childIndex < count_) {
			if (childIndex < count_ - 1 && comparison_(items_[childIndex], items_[childIndex + 1]) < 0) {
				++childIndex;
			}

			if (comparison_(lastItem, items_[childIndex]) < 0) {
				items_[rootIndex] = items_[childIndex];
				rootIndex = childIndex;
				childIndex = childIndex * 2 + 1;
			} else {
				break;
			}
		}

		items_[rootIndex] = lastItem;

		return returnItem;
	}
}


Measured memory_bytes: 37880
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);


    public static void main(String[] args) {
        int N = in.nextInt();
        int K = in.nextInt();

        long ans = 0;
        long[] num = new long[K + 1];
        for (int x = K; x > 0; x--) {
            int kx = K / x;
            num[x] += mpow(kx, N);
            for (int j = 2*x; j <= K; j += x)
                num[x] -= num[j];
            num[x] %= MOD;
            ans += x * num[x];
            ans %= MOD;
        }
        ans += MOD;
        ans %= MOD;
        out.println(ans);

        out.flush();
    }

    static final int MOD = 1_000_000_007;
    static long mpow(long a, long b) {
        if (b == 0) return 1;
        long ret = mpow(a, b >> 1);
        ret = (ret * ret) % MOD;
        if (b % 2 == 1)
            ret = (a * ret) % MOD;
        return ret;
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 33536
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int n;
  cin >> n;
  vector<int> v(n+2, 0);
  for (int i = 1; i <= n; i++){
    cin >> v[i];
  }
  int ans = 0;
  for (int i = 1; i <= n + 1; i++){
    ans += abs(v[i] - v[i-1]);
  }
  // ans += abs(v[n-1]);
  // cout << ans << endl;

  for (int i = 1; i <= n; i++){
    // int res = ans;
    cout << ans - abs(v[i-1] - v[i]) - abs(v[i] - v[i+1]) + abs(v[i-1] - v[i+1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
/**  '' "\n" ^ **/


//typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
            // tree_order_statistics_node_update>
//    new_data_set;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    map<string,int> mp;
    string str;
    while(n--)
    {
        cin>>str;
        sort(str.begin(),str.end());
        mp[str]++;
    }
    map<string,int>::iterator it;
    it=mp.begin();
    ll count=0;
    while(it!=mp.end())
    {
        ll j=it->second;
        j--;
        j=(j*(j+1))/2;
        count+=j;
        it++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 11264
#include <stdio.h>
  
#define N 10000
#define Nil -1
  
typedef struct{
  int p,l,r;
    }Node;
  
Node T[N];
int n,D[N],H[N];
  
void setDepth(int, int);
int setHeight(int);
int getSibling(int);
void print(int);
  
int main(){
  int i,v,l,r,root=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p = Nil;
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
  
    T[v].l = l;
    T[v].r = r;
  
    if(l!=Nil) T[l].p = v;
    if(r!=Nil) T[r].p = v;
  }
  
  for(i=0;i<n;i++)
    if(T[i].p == Nil) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(i=0;i<n;i++)
    print(i);
  
  return 0;
}
  
void setDepth(int u, int d){
  
  if(u==Nil) return;
  
  D[u] = d;
  
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
  
}
  
int setHeight(int u){
  int h1,h2;
  
  h1 = h2 = 0;
  
  if(T[u].l != Nil) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != Nil) h2 = setHeight(T[u].r) + 1;
  
  return H[u] = (h1 > h2 ? h1 : h2); 
}
  
int getSibling(int u){
  
  if(T[u].p ==Nil) return Nil;
  
  if(T[T[u].p].l != u && T[T[u].p].l != Nil)
    return T[T[u].p].l;  
  if(T[T[u].p].r != u && T[T[u].p].r != Nil)
    return T[T[u].p].r;
  
  return Nil;
}
  
void print(int u){
  int deg;
   
  printf("node %d: parent = %d, sibling = %d, ",u,T[u].p,getSibling(u));
   
  deg = 0;
   
  if(T[u].l != Nil)deg++;
  if(T[u].r != Nil)deg++;
   
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
   
  if(T[u].p == Nil)printf("root\n");
  else if(T[u].l == Nil && T[u].r == Nil)printf("leaf\n");
  else printf("internal node\n");
}

Measured memory_bytes: 1840
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    int ans = 0;
    for(int i = 1; i <= N; i++){
        string s = to_string(i);
        if(s.size() & 1) {
            ans++;
        }
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    string o,e;
    string ans;
    cin >> o >> e;
    ll i=0, j=0;
    while(1)
    {

        if(i==o.size() && j==e.size()) break;
        ll sz=ans.size();
        if(sz%2==0)
        {

            ans.pb(o[i]);
            i++;
        }
        else
        {

            ans.pb(e[j]);
            j++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
S = input()
A = ["A", "G", "C", "T"]
count = 0
j = 0
ans = 0
for i in range(len(S)):
    j = i
    while S[i] in A:
        count += 1
        i += 1
        if i == len(S):
            break

    i = j
    ans = max(ans, count)
    count = 0
print(ans)





Measured memory_bytes: 9076
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

template<typename T, typename U>
class SegmentTree{
    int n;
    vector<T> node;

    using F = function<T(T, T)>;
    using G = function<T(T, U)>;

    F f;
    G g;
    T en;

public:
    SegmentTree(int n_, F f_, G g_, T en_){
        init(n_, f_, g_, en_);
    }

    SegmentTree(const vector<T>& dat, F f_, G g_, T en_){
        build(dat, f_, g_, en_);
    }

    void init(int n_, F f_, G g_, T en_){
        n = 1;
        while(n < n_){
            n <<= 1;
        }
        f = f_;
        g = g_;
        en = en_;

        node.resize(n << 1);
        fill(node.begin(), node.end(), en);

        return;
    }

    void build(const vector<T>& dat, F f_, G g_, T en_){
        int n_ = (int)dat.size();

        init(n_, f_, g_, en_);

        for(int i = 0 ; i < n_ ; ++i){
            node[i + n] = dat[i];
        }

        for(int i = n - 1 ; 0 < i ; --i){
            node[i] = f(node[i << 1], node[(i << 1) | 1]);
        }

        return;
    }

    void update(int k, U x){
        k += n;
        node[k] = g(node[k], x);

        while(k >>= 1){
            node[k] = f(node[k << 1], node[(k << 1) | 1]);
        }

        return;
    }

    T get(int l, int r){
        l += n;
        r += n;

        T res = en;
        while(l < r){
            if(l & 1){
                res = f(res, node[l++]);
            }
            l >>= 1;
            if(r & 1){
                res = f(res, node[--r]);
            }
            r >>= 1;
        }

        return res;
    }
};

#include<iostream>
using namespace std;

using lint = long long;

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

    int n, q, com, x;
    lint y;
    cin >> n >> q;

    SegmentTree<lint, lint> seg(n, [](lint l, lint r){ return l + r; }, [](lint l, lint r){ return l + r; }, 0LL);

    while(q--){
        cin >> com >> x >> y;
        if(com == 0){
            seg.update(x - 1, y);
        }else if(com == 1){
            cout << seg.get(x - 1, y) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4928
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - max({a, b, c}) << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools
N,M,Q=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(Q)]


ans=0
for A in itertools.combinations_with_replacement(range(1,M+1),N):
    A=sorted(A)
    total=0
    for k in range(Q):
        if A[(S[k][1]-1)]-A[S[k][0]-1]==S[k][2]:
            total+=S[k][3]
    if total>ans:
        ans=total

print(ans)

Measured memory_bytes: 9128
#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"
#include "numeric"

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;
	cout << (N / 2)*((N + 1) / 2) << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::stdin;

fn main() {
    let mut input_line: String = String::new();
    io::stdin().read_line(&mut input_line).expect("Err");

    let inputs: Vec<&str> = input_line.split_whitespace().collect();

    let n: i32 = inputs[0].parse().unwrap();
    let m: i32 = inputs[1].parse().unwrap();

    let mut students = Vec::new();
    let mut checkpoints = Vec::new();

    // load students pos
    for _i in 0..n {
        let mut tmp_line = String::new();
        stdin().read_line(&mut tmp_line);
        let pos: Vec<&str> = tmp_line.split_whitespace().collect();
        let x:i64 = pos[0].parse().unwrap();
        let y:i64 = pos[1].parse().unwrap();

        students.push([x, y]);
    }

    // load checkpoints pos
    for _i in 0..m {
        let mut tmp_line = String::new();
        stdin().read_line(&mut tmp_line);
        let pos: Vec<&str> = tmp_line.split_whitespace().collect();
        let x:i64 = pos[0].parse().unwrap();
        let y:i64 = pos[1].parse().unwrap();

        checkpoints.push([x, y]);
    }

    for student_id in 0..students.len(){
        // println!("start student_id:{}", student_id);
        let mut will_go_number = 1;
        let mut min_distance = 1000_0000_0000;
        for checkpoint_id in 0..checkpoints.len(){
            let distance = _calc_distance(students[student_id][0], checkpoints[checkpoint_id][0], students[student_id][1],checkpoints[checkpoint_id][1]);
            // println!("checking student_id:{} min_distance:{}(id:{}) calced_distance:{}", student_id, min_distance, checkpoint_id, distance);
            if min_distance > distance{
                will_go_number = checkpoint_id + 1;
                min_distance = distance;
            }
        }
        println!("{}", will_go_number);
    }

}




fn calc_distance(x:[i64;2], y:[i64;2]) -> i64 {
    return _calc_distance(x[0], x[1], y[0], y[1]);
}

fn _calc_distance(x1:i64, x2:i64, y1:i64, y2:i64) -> i64 {
    let mut x = x1 - x2;
    let mut y = y1 - y2;

    if x < 0 { x *= -1; }
    if y < 0 { y *= -1; }

    return x + y;
}

Measured memory_bytes: 2060
#include <stdio.h>

#define MAX 100000
int main(){

  int n,q,s[MAX],t,i,j,count=0;
  int l,m,r;

  //in
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d",&s[i]);
  
  //in
  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&t);
    l=0;
    r=n;
    
    while(l<r){
      m=(l+r)/2;
      if(s[m]==t){
	count++;
	break;
      }
      else if(s[m]<t){
	l=m+1;
      }else if(s[m]>t){
	r=m;
      }else{
	printf("exception %d",t);
      }
    }
  }
  
  //out
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 988
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// お札の枚数
        int targetYen = sc.nextInt();

        int count10000Yen = -1;// 10000円の枚数
        int count5000Yen = -1;// 5000円の枚数
        int count1000Yen = -1;// 1000円の枚数

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                int tmpCount10000Yen = i;// 10000円の枚数
                int tmpCount5000Yen = j;// 5000円の枚数
                int tmpCount1000Yen = n - (i+j);// 1000円の枚数
                if (tmpCount1000Yen < 0) break;// お札の枚数が多すぎる

                int tmpSum = (10000*tmpCount10000Yen) + (5000*tmpCount5000Yen) + (1000*tmpCount1000Yen);
                if (tmpSum == targetYen) {
                    count1000Yen = tmpCount1000Yen;
                    count5000Yen = tmpCount5000Yen;
                    count10000Yen = tmpCount10000Yen;
                    break;
                }
            }
        }

        System.out.println(count10000Yen + " " + count5000Yen + " " + count1000Yen);
    }
}


Measured memory_bytes: 23124
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
using namespace std;
int lst=0,lstx,lsty,n,f;
int read()
{
	int f=1,x=0;
	char ch=getchar();
	while(isdigit(ch)==0 && ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
void write(int x)
{
	char ch[20];
	int f=0;
	if(!x){putchar('0');return;}
	if(x<0){putchar('-');x=-x;}
	while(x)ch[++f]=x%10+'0',x=x/10;
	while(f)putchar(ch[f--]);
	putchar('\n');
}
int main()
{
	n=read();
	while(n--)
	{
	//	cout<<endl;
		int t=read(),x=read(),y=read();
		int tmpt=t-lst,tmpx=abs(x-lstx),tmpy=abs(y-lsty);
	//	cout<<tmpt<<" "<<tmpx<<" "<<tmpy<<endl;
		lst=t,lstx=x,lsty=y;
		if(tmpt==tmpx+tmpy)continue;
	//	cout<<"*";
		if(tmpt<tmpx+tmpy)f=1;
	//	cout<<"+";
	    if((tmpt-tmpx-tmpy)&1)f=1;
	//    cout<<"=";
	}
	if(!f)printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 256