akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX;

fn solve() {
    let (n,d) = read!(usize,i64);
    let xy = read!(i64,i64;n);
    let mut ans = 0;
    for (x,y) in xy {
        let val = x*x + y*y;
        if val<=d*d {
            ans += 1;
        }
    }
    println!("{}",ans);
}

fn run() {
    solve();
}


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

inline int in() { int x; cin >> x; return x; }

/*-------------------------------------------------*/
void solve() {
  int h = in();
  int ans = 0;
  int num = 1;
  while (h) {
    ans += num;
    h /= 2;
    num *= 2;
  }
  cout << ans << endl;
}

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


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

const int INF = 2e9 + 10;

int main() {

    int n, k; scanf("%d%d", &n, &k);

    vector <int> h(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }

    vector <int> dp(n + 1, INF);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= k && i - j >= 0; j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    printf ("%d\n", dp[n - 1]);

    return 0;
}

Measured memory_bytes: 1024
main = do
    str <- getLine
    let d = (judge . takeOne) str
    putStrLn d


takeOne::String -> Char
takeOne n = head $ reverse n 

judge::Char -> String
judge '3' = "bon"
judge '0' = "pon"
judge '1' = "pon"
judge '6' = "pon"
judge '8' = "pon"
judge x = "hon"

Measured memory_bytes: 3728
#include<iostream>                                        
using namespace std;                                      
                                                          
class Cube{                                               
public:                                                   
  int f[6];                                               
  Cube(){}                                                
  void roll_z(){ roll(1,2,4,3);} // ?°´????????????90????????¢    
  void roll_y(){ roll(0,2,5,3);} // to W                  
  void roll_x(){ roll(0,1,5,4);} // to N                  
  void roll(int i,int j,int k,int l){                     
    int t = f[i];f[i] = f[j];f[j] = f[k];f[k] = f[l];f[l]\
 = t;                                                     
  }                                                       
};                                                        
                                                          
bool eq(Cube c1,Cube c2){                                 
  for(int i=0;i<6;i++)                                    
    if(c1.f[i] != c2.f[i]) return false;                  
  return true;                                            
}                                                         
                                                          
bool equal(Cube c1,Cube c2){                              
  for(int i=0;i<6;i++){                                   
    for(int j=0;j<4;j++){                                 
      if(eq(c1,c2)) return true;                          
      c1.roll_z();                                        
    }                                                     
    if(i%2==0)c1.roll_y();                                
    else c1.roll_x();                                     
  }                                                       
  return false;                                           
}                                                         
  int main(){                                               
  Cube c1,c2;                                             
                                                          
  for(int i=0;i<6;i++) cin >> c1.f[i];                    
  for(int i=0;i<6;i++) cin >> c2.f[i];                    
                                                          
  if(equal(c1,c2)) cout << "Yes" << endl;                 
  else cout << "No" << endl;                              
                                                          
  return 0;                                               
} 

Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            foreach(char c in input)
            {
                if (c == ',') Console.Write(" ");
                else Console.Write(c);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 2648
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> vi;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin>>n && n){
        n++;
        vi h(n);
        rep(i,n)cin>>h[i];
        rep(i,n){
            vi t;
            rep(j,n)if(i!=j)t.push_back(h[j]);
            bool ok=true;
            int d=t[1]-t[0];
            rep(j,n-2){
                if(t[j+1]-t[j] != d){
                    ok=false;
                    break;
                }
            }
            if(ok){
                cout<<h[i]<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<ll> X, Y;
    rep(i, n){
        ll a; cin >> a;
        if(i%2==0)X.push_back(a);
        else Y.push_back(a);
    }
    if(n%2==1){
        reverse(all(X));
        for(auto x: X)cout << x << " ";
        for(auto y: Y)cout << y << " ";
    }else{
        reverse(all(Y));
        for(auto y: Y)cout << y << " ";
        for(auto x: X)cout << x << " ";
    }
    cout << ln;
}


Measured memory_bytes: 5056
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    a = a + b;
    b = a - b;
    a = a - b;
    a = a + c;
    c = a - c;
    a = a - c;
    printf("%d %d %d\n",a,b,c);

    return 0;
}


Measured memory_bytes: 128
X,N = map(int, input().split())
num_list = list(map(int, input().split()))
if (len(num_list) == 0) or X not in num_list:
    print(X)
else:
    d = 1
    while True:
        if X - d not in num_list:
            print(X -d)
            break
        elif X + d not in num_list:
            print(X + d)
            break
        else:
            d +=1

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, k, s;
  cin >> n >> k >> s;
  rep(i,k) cout << s << " ";
  rep(i,n-k) {
    if (s == INF) {
      cout << 1 << " ";
    } else {
      cout << s + 1 << " ";
    }
  }
  cout << endl;
}

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

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

int main() {
    int k, a, b;
    long long ans=0;
    cin >> k;
    
    for(int i=1; i<=k; i++) {
        for(int j=1; j<=k; j++) {
            for(int l=1; l<=k; l++) {
                a=__gcd(j, l);
                b=__gcd(i, a);
                ans+=b;
            }
        }
    }
    cout << ans;
}

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

typedef long long ll;

const int N = 9;
int n;
int p[N];
int q[N];

bool equal(int *a, int *b) {
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) return false;
    }
    return true;
}

bool small(int *a, int *b) {
    for (int i = 0; i < n; ++i) {
        if (a[i] < b[i]) return true;
        if (a[i] > b[i]) return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
    }
    int res = 0;
    if (small(p, q)) {
        while (!equal(p, q)) {
            next_permutation(p, p + n);
            ++res;
        }
    } else { // p > q
        while (!equal(p, q)) {
            next_permutation(q, q + n);
            ++res;
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define FREE -1
#define NOT_FREE 1
#define FALSE 0
#define TRUE 1
#define N 8

void queencheck(int);
void printboard(void);

int col[N],row[N],dpos[2*N-1],dneg[2*N-1];
int Q[N][N];

int main(){
  int k,r,c,i,j;
 
  
  for(i=0;i<N;i++){
    col[i]=FREE;
    row[i]=FREE;
    for(j=0;j<N;j++){
      Q[i][j] = FALSE;
    }
  }
  
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
  
  scanf("%d",&k);

  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c);
    Q[r][c] = TRUE;
  }

  queencheck(0);
 
  return 0;
}

void queencheck(int i){
  int j;

  if(i==N){
    printboard();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE)continue;

    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

    queencheck(i+1);

    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

void printboard(void){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(Q[i][j] == TRUE){
	if(row[i] != j)return;
      }
    }
  }
		  

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2108
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
        int b=sc.nextInt();
        int result=0;
        
        if(a>b){
            for(int i=0; i<a; i++){
                System.out.print(b);
            }
        }
        if(a<b){
            for(int i=0; i<b; i++){
                System.out.print(a);
            }
        }
        if(a==b){
            for(int i=0; i<b; i++){
                System.out.print(a);
            }
        }
    }
}

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

int main(){
  string S, T;
  cin >> S >> T;
  
  int count = 0;
  
  for(int i = 0; i < 3; i++) {
    if(S.at(i) == T.at(i)) {
      count++;
    }
  }
  
  cout << count << endl;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define fi first
#define se second

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

    int s, w;
    cin >> s >> w;

    if(w >= s)
        cout << "unsafe";
    else
        cout << "safe";

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long dp[105][100005];
int main()
{
  int n,we;
  long long w[105],v[105];
  cin>>n>>we;

  for(int i=0; i<n; i++){
    cin>>w[i]>>v[i];
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<=we; j++){ 
      if(j>=w[i]){
	dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }else{
	dp[i+1][j]=dp[i][j];
      }
    }
  }

  cout<<dp[n][we]<<'\n';
  return 0;
}


Measured memory_bytes: 79360
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

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

const int mod = pow(10, 9) + 7;



int main(){

	double a, b, x;
	cin >> a >> b >> x;

	double s = x / a;
	double volume = a * b;

	double rad;

	if(s >= volume / 2){
		double h = (volume - s) * 2 / a;
		rad = atan2(h, a);
	} else {
		double w = s * 2 / b;
		rad = atan2(b, w);
	}

	double PI = acos(-1);
	double deg = (rad / (2 * PI)) * 360;

	printf("%.10f\n", deg);

}

Measured memory_bytes: 384
while True:
  n, x = map(int,input().split())
  c = 0
  if n == x == 0:
    break 
  for r in range(1, n-1):
    for s in range(r+1, n):
      for t in range(s+1, n+1):
        if r+s+t == x:
          c += 1
  print(c)


Measured memory_bytes: 5592
#include <iostream>
#include <float.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>
#include <stack>
#include <queue>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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

ll solve(vector<ll> v, int n, bool upper) {
	ll result = 0;
	ll goukei = 0;
	rep(i, n) {
		goukei += v[i];
		if (upper) {
			if (goukei <= 0) {
				result += (1 - goukei);
				goukei = 1;
			}
			upper = false;
		}
		else {
			if (goukei >= 0) {
				result += (1 + goukei);
				goukei = -1;
			}
			upper = true;
		}
	}
	return result;
}

int main() {
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i, n)
		cin >> v[i];
	ll result = min(solve(v, n, false), solve(v, n, true));
	cout << result << endl;

}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int f[n][10], p[n][11];
  REP(i,n) REP(j,10) {
    cin >> f[i][j];
  }
  REP(i,n) REP(j,11) {
    cin >> p[i][j];
  }
  int ans=-INF;
  for (int bit=1; bit < 1<<10; bit++) {
    int sum=0;
    REP(i,n) {
      int c=0;
      REP(j,10) if (bit >> j & f[i][j]) c++;
      sum+=p[i][c];
    }
    ans = max(ans,sum);
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 256
import sys
input  = sys.stdin.readline


def solve():
    N = int(input())
    if N%2==1:
        print(0)
    else:
        ans=0
        i = 10
        while True:
            if N/i < 1:
                break
            else:
                ans += N//i
                i *= 5
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <iostream>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
const int Max_Num=16;
const int INF=1000000;

int V, E;
int dist[Max_Num][Max_Num];
int dp[1<<Max_Num][Max_Num];

int bitDP(int start, int bit, int v){
  if(bit==((1<<V)-1)&&dist[v][start]==INF) return dp[bit][v]=INF;
  if(dp[bit][v]!=-1) return dp[bit][v];
  if(bit==(1<<start)) return dp[bit][start]=0;
  int bitprev=bit-(1<<v);
  int res=INF;
  rep(u,V){
    if(!(bitprev&(1<<u))||dist[u][v]==INF) continue;
    res=min(res,bitDP(start, bitprev, u)+dist[u][v]);
  }
  if(bit==((1<<V)-1)) return dp[bit][v]=res+dist[v][start];
  else return dp[bit][v]=res;
}

int main(){
  cin >> V >> E;
  rep(i,V){
    rep(j,V) dist[i][j]=INF;
  }
  rep(i,E){
    int s, t, d;
    cin >> s >> t >> d;
    dist[s][t]=d;
  }
  int ans=INF;
  rep(start,V){
    rep(i,1<<V){
      rep(j,V) dp[i][j]=-1;
    }
    rep(v,V) ans=min(ans,bitDP(start,((1<<V)-1),v));
  }
  if(ans==INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5152
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    long long int N,D;
    cin>>N>>D;
    long long int cou=0;
    for(int i=0;i<N;i++){
        long long int a,b;
        cin>>a>>b;
        if(a*a+b*b<=D*D)cou++;
    }
    cout<<cou<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

	int x, a;
	cin >> x >> a;
	if(x < a){
		cout << 0 << endl;
	}else{
		cout << 10 << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500000
int A[MAX];
int H;
void maxheap(int *,int);

int main(){
int i;
  scanf("%d",&H);
  for (i = 1; i <= H; i++ ) {
    scanf("%d",&A[i]);
  }
  for (i = H/2 ; i > 0 ; i-- ){
    maxheap(A,i);
  }
  for (i=1 ; i<=H ;i++){
    printf(" %d",A[i]);
  }
  puts("");

  return 0;

}

void maxheap(int A[],int i){

  int l,r;
  int large,temp;

  l=i*2;
  r=i*2+1;

  if (l<=H && A[l]>A[i])large=l;
  else large=i;

  if (r<=H && A[r]>A[large])large=r;

  if(large!=i){
    temp=A[i];
    A[i]=A[large];
    A[large]=temp;
    maxheap(A,large);
  }
}

Measured memory_bytes: 4644
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    ans = 0
    for i, a in enumerate(A):
        if (i + 1) % 2 == a % 2 == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

int main(){
  int a, b;cin >> a >> b;
  int t = b;
  int cnt = 0;
  while(t){
    cnt++;
    t /= 10;
  }
  a *= pow(10, cnt);
  a += b;
  int s = sqrt(a);
  if(s * s == a){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3808
#include <stdio.h>

main(){
  int a,b,c;
  
  scanf("%d%d",&a,&b);
  if(1<a<10^9 && 1<b<10^9){
    while(a%b!=0){
      c=a%b;
      a=b;
      b=c;
    }
  printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

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

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< long long int, long long int > prime_factor(long long int n) {//素因数分解
    map< long long int, long long int > ret;
    for(long long int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}



int main() {

    int N;
    cin >> N;
    vector<pair<long long int,long long int>> datas(N);

    bool flag = true;

    for(int i=0;i<N;i++){
        long long int A,B;
        cin >> A >> B;
        datas[i].first = B;
        datas[i].second = A;

    }

    sort(datas.begin(),datas.end());

    long long int time = 0;

    for(int i=0;i<N;i++){
        time+=datas[i].second;
        //cout << datas[i].first << " " << datas[i].second << endl;
        //cout << time << endl;

        if(time>datas[i].first){
            flag = false;
            break;
        }

    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;

    }

}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	while (cin >> str)
	{
		int count = 0,total=0;
		int size = (int)str.size();
		for (int i = 0; i < size; i++)
		{
			if (str[i] == 'R')
			{
				count++;
			}
			else
			{
				total = max(total, count);
				count = 0;
			}
		}
		total = max(total, count);
		cout << total << '\n';
	}
}

Measured memory_bytes: 3536
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		long N = keyboard.nextLong();
		int K = keyboard.nextInt();
		int ans = 0;
		
		while(N > 0) {
			N /= K;
			ans++;
		}
			
		System.out.println(ans);
		keyboard.close();	
	}
}

Measured memory_bytes: 35844
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<((int)n);i++)
#define REP(i,n)	for(int i=0;i<=((int)n);i++)
#define srep(i,a,n)	for(int i=a;i<((int)n);i++)
#define SREP(i,a,n)	for(int i=a;i<=((int)n);i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a % b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n, c;	cin >> n >> c;
	vector<vint> d(c, vint(c));
	rep(i, c)	rep(j, c)	cin >> d[i][j];
	vector<vint> g(n, vint(n));
	rep(i, n)	rep(j, n)	cin >> g[i][j];
	vector<vint> change(3, vint(c, 0));
	rep(i, 3) {
		rep(j, c) {
			rep(a, n)	rep(b, n) {
				if ((a + b) % 3 == i)	change[i][j] += d[g[a][b] - 1][j];
			}
		}
	}
	int ret = mod;
	rep(i, c)	rep(j, c)	rep(k, c) {
		if (i == j || i == k || j == k)	continue;
		int tmp = change[0][i] + change[1][j] + change[2][k];
		ret = min(ret, tmp);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main()
{
    int a,flag=0,ihigh;
    scanf("%d",&a);

    int i=a;
    while(i>0)
    {   flag=0;
        for(int j=2;j<i;j++)
        {
            if(i%j==0)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            ihigh=i;
            break;
        }
        i++;
    }
   printf("%d",ihigh);
}

Measured memory_bytes: 128
store = ["A","B","C","D","E"]
loop do
	str=gets.chomp.split(" ")
	if str[0] == "0" && str[1] == "0"
		break
	end 
	s= str[0].to_i+str[1].to_i
	num=0
	4.times do |i|
		str=gets.chomp.split(" ")
		y=str[0].to_i+str[1].to_i
		 if s < y
		 	s = y
		 	num = i+1
		 end
	end
	puts "#{store[num]} #{s}" 
end

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    for (int i=0;i<H;++i){
        for (int j=0;j<W;++j){
            string S; cin >> S;
            if (S=="snuke") cout << (char)('A'+j) << i+1 << '\n';
        }
    }
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  while(true){
    int n, x;
    cin >> n >> x;
    if(n == 0 && x == 0) break;
    int ans = 0;
    FOR(i, 1, n){
      FOR(j, i+1, x-i+1){
        if((x-i-j) > j && (x-i-j) <= n) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,X;
  cin>>A;
  cin>>B;
  cin>>C;
  cin>>X;
 int count;
for(int i=0;i<=A;i++){
	for(int j=0;j<=B;j++){
		for(int k=0;k<=C;k++){
			if(500 *i + 100*j + 50 *k == X  ){
            	count++;
            	}
			}
		}
	}
 cout<<count<<endl; 
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

x = inp()
for i in range(-2000,2000):
    for j in range(-2000,2000):
        if pow(i,5) - pow(j,5) == x:
            print(i,j)
            quit()

Measured memory_bytes: 91064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{

	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	

	
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int sum = a + b;
    if (sum%2 == 0) cout << sum / 2 << endl;
    else cout << sum/2 + 1 << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

const int M = 321;
const int N = 90034;

int a[M][M];
int x[N], y[N];
int c[N];

void solve() {
    int h, w, d; scanf("%d%d%d", &h, &w, &d);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            scanf("%d", a[i]+j);
            x[a[i][j]] = j; y[a[i][j]] = i;
        }
    }
    for (int i = 1; i <= h*w; ++i) {
        if (c[i]) continue;
        for (int j = i+d; j <= h*w; j+=d) {
            c[j] = c[j-d]+abs(x[j]-x[j-d])+abs(y[j]-y[j-d]);
        }
    }
    int q; scanf("%d", &q);
    while (q--) {
        int l, r; scanf("%d%d", &l, &r);
        debug(c[r]);
        debug(c[l]);
        printf("%d\n", c[r]-c[l]);
    }
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
class UnionFind
  require 'set'
  def initialize(size)
    @rank = Array.new(size) { 0 }
    @parent = Array.new(size) { |id| id }
    @set = Set.new(@parent)
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  def same?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end

  def size
    temp = Set.new()
    @set.each do |id_x|
      temp.add(get_parent(id_x))
    end
    (@set = temp).size
  end
end

nn, mm = gets.chomp.split.map(&:to_i)

q = []
1.step(mm, 1) do |_i|
  q.push(gets.chomp.split.map { |g| g.to_i - 1 })
end

ans = 0
0.step(mm - 1, 1) do |i|
  union = UnionFind.new nn
  0.step(mm - 1, 1) do |j|
    next if i.eql? j

    union.unite(*q[j])
  end
  ans += 1 unless union.size.eql?(1)
end

p ans

Measured memory_bytes: 2172
// #include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
// #include <algorithm>
#define pb push_back
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f first
#define s second
// #define cerr if(0)cerr
using namespace std;
typedef long long LL;
typedef pair<int,LL> PILL;

const int N=110;
const LL  I=1e18;
int n,W;
PILL T[N];
LL DP[100010];

LL maxi(LL x, LL y)
{
  if(y>x)return y;
  return x;
}

int main()
{
  // boost;
  scanf("%d%d",&n,&W);
  for(int i=1; i<=n; i++)
  {
    scanf("%d%lld",&T[i].f,&T[i].s);
  }
  for(int i=1; i<=n; i++)
  {
    for(int j=W; j>=T[i].f; j--)
    {
      DP[j]=maxi(DP[j],DP[j-T[i].f]+T[i].s);
    }
  }
  printf("%lld",DP[W]);

  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define lln long long int
using namespace std;
bool prim[1000];
lln arr[1000];
lln pp=0;
int seive()
{
    for(lln i=3;i*i<=1000;i++)
    {
        if(prim[i]==false)
        {
            for(lln j=i*i;j<=1000;j+=i+i)
            {
                prim[j]=true;
            }
        }
    }
    arr[pp++]=2;
    for(lln i=3;i<=1000;i+=2)
    {
        if(prim[i]==false)
        {
            arr[pp++]=i;
        }
    }
}
lln arr2[1000];
int main()
{
    lln n;
    seive();
    //for(int i=0;i<pp;i++)cout<<arr[i]<<endl;
    cin>>n;
    lln p=0,res=1;
    for(lln i=0;arr[i]<=n && i<pp;i++)
    {
        lln nn=n,sum=0;
        while(nn>0)
        {
            sum+=(nn/arr[i]);
            //cout<<sum<<" "<<nn<<endl;;
            nn/=arr[i];
        }
        //cout<<endl;
        sum++;
        res=(res*sum)%1000000007;
        //cout<<res<<endl;
    }
    cout<<res;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ab(x) ((x)>0?(x):(x)*(-1))
#define ll long long
using namespace std;
const int N=100005;
int n,now,a[N];ll s=0;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s+=ab(a[i]-a[i-1]);
	}
	s+=ab(a[n]);
	for(int i=1;i<=n;i++) {
		now=s-ab(a[i]-a[i-1])-ab(a[i+1]-a[i])+ab(a[i+1]-a[i-1]);
		
		cout<<now<<"\n";
	}
}

Measured memory_bytes: 1664
N=int(input())
count=0
counti=0

for i in range(1,N+1,2):
    if(counti==8):
        count+=1
    counti=0
    
    for j in range(1,i+1):
        if(i%j==0):
            counti+=1

if(counti==8):
    count+=1



print(count)


Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<vector>
using namespace std;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string n;
	cin>>n;	
	cout<<n[0]<<n[1]<<n[2]<<endl;
	
	
	
	
} 

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int N,S,n;
	cin >> N;
	S=0;
	n = N;
	while(n>0){
		S+= n%10;
		n /= 10;
	}
	errln(S);
	println(((N%S==0)?"Yes":"No"));

}


Measured memory_bytes: 256
#include<iostream>

int main(int argc, char const *argv[]) {
  int a, b;
  std::cin >> a;
  std::cin >> b;
  if(a >= 1 && b <= 100){
    int square = a * b;
    int length = 2 * (a + b);
    std::cout << square << " " << length << "\n";
  }

  return 0;
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define inf 0x7fffffff
#define mkp make_pair
#define maxn 100205
typedef unsigned int U;
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const  double eps = 1e-8;
const double pi = acos(-1);
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
int n,m;
char s[1000005];
int main(){
	int i,j;
	//freopen("a.out","r",stdin);
	//freopen("a.ans","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);
	int cnt=0;
	for(i=1;i<=n;i++){
		if(s[i]!=s[i-1]) cnt++;
	}
	printf("%d\n",cnt-1);
	return 0;
}

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
typedef long long int lli;
typedef long long ll;
typedef long double ld;

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

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll ans=0;
        while(n>0){
            if(n/500>0){
                ans+=1000*(n/500);
                n-=500*(n/500);
            }
            else if(n/5>0){
                ans+=5*(n/5);
                n-=5*(n/5);
                n=0;
            }
        }
        cout<<ans<<endl;
    }   
    return 0;
}


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

int main()
{
	int nums[100]={0};
	int max=0;
	for (int n; cin >> n;) {
		nums[n-1]++;
		if (nums[n-1]>max) {
			max=nums[n-1];
		}
	}
	for (int i=0; i<100; i++) {
		if (max==nums[i]) {
			cout << i+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<int> data;

public:
	UnionFind(int size) : data(size, -1) { }

	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	bool unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			return true;
		}
		return false;
	}
};


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		
		int x, y, z;
		cin >> x >> y >> z;
		x--, y--;

		uf.unify(x, y);

	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (uf.root(i) == i) ans++;
	}

	cout << ans << "\n";

	return 0;
}

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

using namespace std;

const int maxi=1e6;
long long a[maxi],sum[maxi];
int n;

int main()
{

   cin>>n;

   for (int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }

  long long ans=1e15;

    for (int i=1;i<=n-1;i++)
        ans=min(ans,abs(sum[n]-sum[i]*2));

    cout<<ans;
   return 0;
}
//Nothing is regular !!!


Measured memory_bytes: 5888
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N, A, B;
    cin >>  N >> A >> B ;
    
    ll ans = N, ans1 = N , ans2 = N;
    if(abs(A-B) % 2 == 0) ans = abs(A-B) / 2;
    else{
        ans = min(ans, ((A-1) + (B-1) + 1)/2);
        
        ans = min(ans, ((N-A) + (N-B) + 1)/2);
    }
    
    cout << ans << endl;
    

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int map[5][5];

bool isRec(int y, int x, int h, int w)
{
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            if (map[y + i][x + j] == 0)
                return false;
    return true;
}

int Check()
{
    int ans = 0;
    for (int h = 5; h >= 1; --h)
        for (int w = 5; w >= 1; --w)
            for (int i = 0; i + h <= 5; ++i)
                for (int j = 0; j + w <= 5; ++j)
                    if (map[i][j] == 1 && isRec(i, j, h, w))
                        ans = max(ans, h * w);
    return ans;
}

int main()
{
    int testcase;

    cin >> testcase;
    while (testcase--) {
        // Input
        for (int i = 0; i < 5; ++i)
            for (int j = 0; j < 5; ++j)
                cin >> map[i][j];

        cout << Check() << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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


signed main(){
	
	ll n,a,b;
	cin >> n >> a >> b;
	
	cout << min(a,b) << " " << max( (a+b) - n, (ll)0) << endl;
	
	
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll choose2(ll n)
{
    if(n<0)
    {
        return 0;
    }
    return n*(n-1)/2;
}
long long modpow(long long a,long long n,long long p)
{
    if(n==1)
    {
        return a%p;
    }
    if(n%2==1)
    {
        return a*modpow(a,n-1,p)%p;
    }
    long long t = modpow(a,n/2,p);
    return t*t%p;
}
 
//O(K)でnCkを求める
int comb( int N, int K ){
  int X = 1; //分子
  int Y = 1; //分母
  for( int i = N; i > N-K; i-- ){
    X = (X*i)%MOD;
  }
  for( int i = 1; i <= K; i++ ){
    Y = (Y*i)%MOD;
  }
  return X * modpow(Y, MOD-2, MOD)%MOD;   //Aの逆元を取る場合、modpow(A, MOD-2, MOD) https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a 3-4参照
}

int main()
{
    /*A
    int n,m;
    cin>>n>>m;
    int count;
    count = (n*(n-1)/2+m*(m-1)/2);
    cout<<count<<endl;
    */

    /*B
    string s;
    cin>>s;
    int n = s.size();
    bool flag = true;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-1-i])
        {
            flag = false;
        }
    }
    
    for(int i=0;i<(n-1)/2;i++)
    {
        if(s[i]!=s[(n-1)/2-(i+1)])
        {
            flag = false;
        }
    }
    for(int i=(n+3)/2;i<n;i++)
    {
        if(s[i]!=s[n-(i+1)])
        {
            flag = false;
        }
    }

    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    */
    /*
    int l;
    cin>>l;
    double a;
    a = (double) l/3;

    cout<<setprecision(12)<<a*a*a<<endl;
    */
    /*
    int n;
    cin>>n;
    vector <int> a(n);
    rep(i,n)
    {
        cin>>a[i];
    }
    rep(i,n)
    {
        a[i]--;
    }
    vector <int> cnt(n);
    rep(i,n)
    {
        cnt[a[i]]++;
    }
    ll sum = 0;
    rep(i,n)
    {
        sum+=choose2(cnt[i]);
    }
    rep(i,n)
    {
        ll ans = sum;
        ans-=choose2(cnt[a[i]]);
        ans+=choose2(cnt[a[i]]-1);
        cout<<ans<<endl;;
    }

    */
    int n;
    cin>>n;
    vector <int> a(n);
    map <int,int> mp;
    rep(i,n)
    {
        cin>>a[i];
        mp[a[i]]++;
    }

    set <int> s;
    rep(i,n)
    {
        s.insert(a[i]);
    }

    ll sum = 0;
    for(auto itr=s.begin();itr!=s.end();itr++)
    {
        sum += choose2(mp[*itr]);
    }

    rep(i,n)
    {
        ll total = sum;
        total -= choose2(mp[a[i]]);
        total +=choose2(mp[a[i]]-1);
        cout<<total<<endl;
    }
    return 0;
}

Measured memory_bytes: 14208
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    int cur = 0;
    forn (i, 0, 3) {
        if (s[i] == 'R') {
            ++cur;
            chkmax(ans, cur);
        } else {
            cur = 0;
        }
    }
    chkmax(ans, cur);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	char a[150];
	for (int i = 0; i < 9; i++) {
		cin >> a[i];
	}
	
	cout << "A" << a[7] << "C" << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;

	int t = m * 1900 + (n - m) * 100;
	for(int i=0; i<m; ++i)
		t *= 2;
	cout << t << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N; // 2<=N<=2*10^5
    vll a(N); // -10^9<=a[i]<=10^9
    ll sm = 0;
    rep(i, N) {
        cin >> a[i];
        sm += a[i];
    }

    ll ans = LLONG_MAX, x = 0, y = sm;
    rep(i, N - 1) {
        x += a[i];
        y -= a[i];
        smin(ans, abs(x - y));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792