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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, m;

	cin >> n >> m;

	cout << (n - 1)*(m - 1) << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))

table = [1] * (n+1)
table[0] = 0

for _ in [0]*m:
    a, b = list(map(int, input().split()))
    if h[a] > h[b]:
        table[b] = 0
    elif h[a] < h[b]:
        table[a] = 0
    else:
        table[a] = 0
        table[b] = 0

print(sum(table))

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

int main(){

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int a, b;
  a=tx-sx; 
  b=ty-sy;
  
  for(int i=0; i<a; i++){
  cout << 'R';
  }
   for(int i=0; i<b; i++){
  cout << 'U';
  }
  for(int i=0; i<a; i++){
  cout << 'L';
  } 
  for(int i=0; i<b; i++){
  cout << 'D';
  } 
  cout << 'L';
  for(int i=0; i<(b+1); i++){
  cout << 'U';
  }
  for(int i=0; i<(a+1); i++){
  cout << 'R';
  }
  cout << 'D' << 'R';
  for(int i=0; i<(b+1); i++){
  cout << 'D';
  }
  for(int i=0; i<(a+1); i++){
  cout << 'L';
  }
  cout << 'U' << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
 
  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
//   typedef string str;
//   typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;
  
 

  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> have(n+1);
  for (int i = 0;i<n;i++){
    cin >>a[i];
    if (i+1-a[i]>=2){
      have[i+1-a[i]]++;
    }
  }
  ll ans= 0;
  for (int i = 0;i<n;i++){
    if (i+1+a[i]<=n){
       ans+= have[i+1+a[i]];
    }
   if (i+1-a[i]>=2){
      have[i+1-a[i]]--;
   }
  
  }
  cout<<ans<<"\n";

}
  

Measured memory_bytes: 4348
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
 
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solutions

int32_t main()
{
    IOS

    
    int n,p;
    cin>>n>>p;

    string s;

    cin>>s;
    int po[n+1];
    po[0]=1;

    for(int i=1;i<=n;i++)
    {
        po[i]=po[i-1]*10;
        po[i]%=p;
    }
    
    int num=0;

    int ans=0;
    if(p==2 or p==5)
    {
        for(int i=0;i<s.length();i++)
        {
            if((s[i]-'0')%p==0)
                ans+=i+1;
        }
        cout<<ans;
        return 0;
    }
    map<int,int> m;
    m[0]++;
    int x=1;
    for(int i=n-1;i>=0;--i)
    {
        num=(s[i]-'0')*x+num;
        num%=p;
        ans+=m[num];
        m[num]++;   
        x*=10;
        x%=p;
    }
    cout<<ans;
}       

Measured memory_bytes: 2580
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include<cmath>
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// --------------------------------------------------------------------------

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll S;
  cin >> S;
  combination c(1000000);
  mint ans = 0;
  for(int i=1; i<=S; i++){
    if(i*3 > S) break;
    ans += c(i+S-i*3-1,S-i*3);
  }
  cout << ans.x << "\n";
  return 0;
}


Measured memory_bytes: 18772
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    use itertools_num::ItertoolsNum as _;
    input! {
       N: i64,
    }

    let mut ans: usize = 0;
    if N >= 30 {
        echo!("Yes");
    } else {
        echo!("No");
    }
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x, res=1;
	cin>>x;
	for(int i=2;i<=x;i++)
		for(int j=2;pow(i,j)<=x;j++)
			res=max(res,(int)pow(i,j));
	cout<<res;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int a[][] = new int[n][m];
        int b[][] = new int[m][l];
        long ans[][] = new long[n][l];
        int i=0,j=0,k=0;
        for(i = 0 ; i < n ; i++)
        {
            for(j = 0 ; j < m ; j++)
                a[i][j] = sc.nextInt();
        }
        for(i = 0 ; i < m ; i++)
        {
            for(j = 0 ; j < l ; j++)
                b[i][j] = sc.nextInt();
        }
        for(i = 0 ; i < n ; i++)
        {
            for(j = 0 ; j < l ; j++)
                ans[i][j] = 0;
        }
        for(i = 0 ; i < n ; i++)
        {
            for(j = 0 ; j < l ; j++)
            {
                for(k = 0 ; k < m ; k++)
                    ans[i][j] += a[i][k] * b[k][j];
            }
        }
        for(i = 0 ; i < n ; i++)
        {
            for(j = 0 ; j < l-1 ; j++)
                System.out.print(ans[i][j] + " ");
            System.out.println(ans[i][l-1]);
        }
    }
}


Measured memory_bytes: 53448
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d[3][200],ans;
int main()
{
    cin>>a;
    for(int s=1;s<=2;s++)
    {
    	for(int v=1;v<=a;v++)
    	{
    		cin>>b;
    		d[s][v]=d[s][v-1]+b;
		}
	}
	for(int s=1;s<=a;s++)
	{
		ans=max(d[2][a]+d[1][s]-d[2][s-1],ans);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[4][4],i,j;
bool b[4][4];
bool check()
{
	for(i=1;i<=3;i++)
	{
		if(b[i][1]+b[i][2]+b[i][3]==3)
		{
			return 1;
		}
	}
	for(i=1;i<=3;i++)
	{
		if(b[1][i]+b[2][i]+b[3][i]==3)
		{
			return 1;
		}
	}
	if(b[1][1]+b[2][2]+b[3][3]==3)
	{
		return 1;
	}
	if(b[1][3]+b[2][2]+b[3][1]==3)
	{
		return 1;
	}
	return 0;
}
int main()
{
	for(i=1;i<=3;i++)
	{
		for(j=1;j<=3;j++)
		{
			cin>>a[i][j];
			b[i][j]=0;	
		}
	}
	int n,x_pos=0,y_pos=0;
	cin>>n;
	int x[n+1];
	for(int k=1;k<=n;k++)
	{
		cin>>x[k];
		x_pos=0,y_pos=0;
		for(i=1;i<=3;i++)
		{
			for(j=1;j<=3;j++)
			{
				if(a[i][j]==x[k])
				{
					x_pos=i;
					y_pos=j;
					break;
				}
			}
		}	
		if(x_pos!=0&&y_pos!=0)
		{
			b[x_pos][y_pos]=1;
		}
	}
	if(check())
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
int n, m, x[N], y[N], k, ans;
map<pair<int, int>, bool> M;
int v[N];
int main() {
	cin >> n >> m >> k;
	ans = n;
	for (int i = 1; i <= n; ++i) v[i] = m + 1;
	v[n + 1] = 1;
	for (int i = 1; i <= k; ++i) {
		scanf("%d %d", x + i, y + i);
		M[mk(x[i], y[i])] = 1;
		//v[y[i]].push_back(x[i]);
		//v[x[i]].push_back(y[i]);
		v[x[i]] = min(v[x[i]], y[i]);
	}
	for (int i = 1; i <= n; ++i) M[mk(i, m + 1)] = 1;
	int tmp = 0;
	for (int i = 1; i < n; ++i) {
		if (v[i + 1] <= tmp + 1) ans = min(ans, i);
		if (!M.count(mk(1 + i, tmp + 2))) ++tmp;
	}
	/*for (int i = 1; i <= m; ++i) {
		v[i].push_back(n + 1);
		sort(v[i].begin(), v[i].end());
	}
	for (int i = 0; i < m; ++i) {
		int y = 1 + i;
		auto it = lower_bound(v[y].begin(), v[y].end(), y);
		
	}*/
	cout << ans;
}

Measured memory_bytes: 27648
#include<bits/stdc++.h>
using namespace std;
long long int a,b,n,res,mn; 
int main()
{

 cin>>a>>b>>n;
 
 mn=min(b-1,n);
 
 res = floor((a*mn)/b);
 
 
 cout<<res;
 
 return 0;
}


Measured memory_bytes: 3600
using System;

class B{
  static void Main(){
    string S = Console.ReadLine();
    string A = Console.ReadLine();
    int ans = 1000, f = 0;
    for (int i = 0; i <= S.Length - A.Length; i++){
      f = 0;
      for (int j = 0; j < A.Length; j++){
        if (S.Substring(i + j, 1) != A.Substring(j, 1)) f++;
      }
      ans = Math.Min(ans, f);    
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 21408
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

	vector<long long> k(n + 1);
	for(int i = 0; i < n; ++i){
		cin >> k[i];
	}
	k[n] = 1LL << 62;

	sort(k.begin(), k.end());
	long long s = 0;
	for(int i = 0; ; ++i){
		if(k[i] > s + 1) break;
		s += k[i];
	}
	
	cout << s + 1 << endl;
}

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

int main(){
  int K,A,B,k=0;
  cin>>K>>A>>B;
  for(int i=A;i<=B;i++){
    if(i%K==0){
    cout<<"OK"<<endl;
      break;
    }else{
   k++;
  }
  }
  if(k==B-A+1){
  cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3620
N = int(input())
S = input()

ans = set()
for i in range(10):
    i_index = S.find(str(i))
    if i_index == -1:
        continue
    for j in range(10):
        j_index = S.find(str(j), i_index+1)
        if j_index == -1:
            continue
        for k in range(10):
            k_index = S.find(str(k), j_index+1)
            if k_index == -1:
                continue
            ans.add("{}{}{}".format(i, j, k))

print(len(ans))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
struct MaxFlow{
	using D = int;
	const D inf = 1e9;
	struct edge{
		int to;
		D cap;
		int rev;
		edge(int to,D cap,int rev):to(to),cap(cap),rev(rev){}
	};

	int V;
	vector<vector<edge>> G;
	vector<int> level,iter;

	MaxFlow(int V):V(V){
		G = vector<vector<edge>>(V);
		level = vector<int>(V);
		iter = vector<int>(V);
	}

	void add_edge(int from, int to, D cap){
		edge e1(to,cap,(int)G[to].size());
		edge e2(from,0,(int)G[from].size());
		G[from].push_back(e1);
		G[to].push_back(e2);
	}
	void bfs(int s){
		level = vector<int>(V,-1);

		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(int i=0;i<(int)G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0 && level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	D dfs(int v,int t,D f){
		if(v==t) return f;
		for(int &i=iter[v];i<(int)G[v].size();i++){
			edge &e=G[v][i];
			if(e.cap>0 && level[v]<level[e.to]){
				D d = dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	D max_flow(int s,int t){
		D flow=0;
		while(true){
			bfs(s);
			if(level[t]<0) return flow;
			iter = vector<int>(V,0);
			D f;
			while( (f=dfs(s,t,inf))>0 ) flow+=f;
		}
	}
};

int N,M,S,T;
int d[200][200];
int waf[200][200];
int cost[200][200];
int main(){
	cin>>N>>M>>S>>T;
	S--,T--;
	rep(i,N) rep(j,N) if(i!=j) waf[i][j] = d[i][j] = 1e8;
	rep(i,M){
		int x,y,dd,c;
		cin>>x>>y>>dd>>c;
		x--,y--;
		d[x][y] = dd;
		waf[x][y] = dd;
		cost[x][y] = c;
	}
	rep(i,N) rep(j,N) rep(k,N) chmin(waf[j][k],waf[j][i]+waf[i][k]);

	MaxFlow MF(N);

	rep(i,N) rep(j,N) if(i!=j){
		if(waf[S][i] + d[i][j] + waf[j][T] == waf[S][T]){
			MF.add_edge(i,j,cost[i][j]);
		}
	}
	cout<<MF.max_flow(S,T)<<endl;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N, W;
    cin >> N >> W;
    int N_MAX = 110;
    int W_MAX = 20010;
    int v[N_MAX];
    int w[N_MAX];
    REP(i, N){
        cin >> v[i] >> w[i];
    }
    int DP[W_MAX];
    REP(i, N){
        for (int j=W;j>=0;j--){
            if(j + w[i] <= W){
                DP[j+w[i]] = max(DP[j+w[i]], DP[j] + v[i]);
            }
        }
    }
    cout << DP[W] << endl;
    return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>

int main(){
    int a,b,t;
    
    scanf("%d %d %d",&t,&a,&b);
    
    if((t*a)<=b){
        printf("%d\n",t*a);
    }
    
    else{
        printf("%d\n",b);
    }
    
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>; using vi2 = vector<vi>;
#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)

int main() {
	ld a, b; cin >> a >> b;
	cout << ll(a * b) << endl;
}

Measured memory_bytes: 3732
import itertools
l1 = list(map(int,input().split(" ")))
l2 = list(map(int,input().split(" ")))
l3 = list(map(int,input().split(" ")))

flag = True
diffs = []
for i in range(3):
    diffs.append(l1[i]-l2[i])

if len(set(diffs)) != 1:
    flag = False


diffs = []
for i in range(3):
    diffs.append(l2[i]-l3[i])

if len(set(diffs)) != 1:
    flag = False

if flag:
    print("Yes")
else:
    print("No")

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

int main(){
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    printf("%d %d %.5f\n", d, r, f);
    return 0;
}



Measured memory_bytes: 3212
N,C=map(int, input().split())
IA=[[int(i) for i in input().split()] for _ in range(N)]
MS=[[(0, 0)]*(N+1),[(0, 0)]*(N+1)]
CS=[0]*(N+1)
cum = 0
for i,[a,v] in enumerate(IA):
    cum += v
    MS[0][i+1]=(cum-a,a)if(cum-a)>MS[0][i][0]else MS[0][i]
    MS[1][i+1]=(cum-2*a,a)if(cum-2*a)>MS[1][i][0]else MS[1][i]
    CS[i+1]=cum
resmax = 0
for i in range(N):
    oasum1, x = MS[0][i]
    oasum2, x = MS[1][i]
    ob = CS[N] - CS[i]
    resmax = max(resmax, ob + oasum1 - 2*(C-IA[i][0]), ob + oasum2 - (C-IA[i][0]))
print(max(resmax, MS[0][N][0], 0))


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

struct UnionFind {
  vector<int> data;
  UnionFind(int n) : data(n, -1) {}
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[x] > data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
  int n, m; cin >> n >> m;
  vector<int> p(n); REP(i,n) cin >> p[i];
  UnionFind uf(n);
  REP(i,m) {
    int x, y; cin >> x >> y;
    uf.merge(x-1, y-1);
  }
  int ans = 0;
  REP(i,n) {
    if (uf.same(p[i]-1, i))
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
PROGRAM ATCODER
implicit none
character(len=10**5) :: s
integer :: i, len

read(*,*) s

len = len_trim(s)

do i = 1, len
	if(s(i:i) == s(i+1:i+1))then
    	print'(i0," ",i0)', i, i+1
        stop
    end if
    if(s(i:i) == s(i+2:i+2))then
    	print'(i0," ",i0)', i, i+2
        stop
    end if
end do

print'(i0," ",i0)', -1,-1

END PROGRAM ATCODER

Measured memory_bytes: 700
# input
N, M = map(int, list(input().split()))
A = list(map(int, input().split()))

# process
A.sort(reverse=True)

# 1回の握手の幸福度がx以上となるものの数、幸福度の合計を求める
def calc(x):
    count, sum = 0, 0

    j, t = 0, 0
    for i in reversed(range(N)):
        while j < N and A[i]+A[j] >= x:
            t += A[j]
            j += 1
        count += j
        sum += A[i]*j + t
    
    return (count, sum)

# 2分探索で答えを求める
def binary_search(x, y):
    mid = (x+y)//2

    count, sum = calc(mid)
    
    if count < M:
        return binary_search(x, mid)
    else:
        if x == mid:
            print(sum-(count-M)*mid)
        else:
            return binary_search(mid, y)

# 実行
binary_search(0, A[0]*2+1)


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	ll a; cin >> a;
	string b; cin >> b;
	b.erase(1, 1);
	ll c = 0;
	for (int i=0; i<3; i++) {
		c += (b[i] - '0') * pow(10, 2-i);
	}
	cout << (a * c)/100 << endl;
	return 0;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
int main(){
    vector <long long> v;
    long long a,b,c,i;
    string s;
    cin>>s;
    if(s=="ABC"){
    	cout<<"ARC";
	}
	else{
		cout<<"ABC";
	}
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int n;
ll a[100010];

ll calc(bool state) {
  ll cur = 0;
  ll ret = 0;
  rep(i,n) {
    cur += a[i];
    if( state ) { // +
      if( cur == 0 ) {
	++cur;
	++ret;
      } else if( cur < 0LL ) {
	ret += (llabs(cur)+1LL);
	cur += (llabs(cur)+1LL);
      }
    } else { // -
      if( cur == 0 ) {
	--cur;
	++ret;
      } else if( cur > 0LL ) {
	ret += (llabs(cur)+1LL);
	cur -= (llabs(cur)+1LL);
      }
    }
    state = !state;
  }
  return ret;
}

void compute() {
  ll ans = LLONG_MAX;
  rep(i,2) ans = min(ans,calc(i));
  cout << ans << endl;
}

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  compute();
  return 0;
}


Measured memory_bytes: 1024
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;
int cnt;
int arr[maxn];
int ps[maxn];
int main(){
	migmig;
	int n;
	int m;
	int l,r;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>l>>r;
		arr[l]+=1;
		arr[r+1]-=1;
	}
	ps[0]=arr[0];
	for(int i=1;i<=1e5;i++){
		ps[i]=ps[i-1]+arr[i];
		if(ps[i]==m){
			cnt++;
		}
	}
	cout<<cnt;
	
	return 0;
}



Measured memory_bytes: 1024
N,K=map(int,input().split())

a=list(map(int,input().split()))
tentou1=0
for i in range(len(a)):
  for j in range(i+1,len(a)):
    if(a[i]>a[j]):
      tentou1+=1
a.sort()
a.reverse()
stentou=0
for i in range(len(a)):
  for j in range(i+1,len(a)):
    if(a[i]>a[j]):
      stentou+=1
answer=tentou1*K + stentou*K*(K-1)//2
print(answer%1000000007)


Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		long result = 0;
		int[] cnt = new int[n+1];
		Arrays.fill(cnt, 1);
		cnt[0] = 0;
		for(int i = 2; i <= n; i++){
		    int j = i;
		    int c = 1;
		    while(j*c <= n){
		        cnt[j*c]++;
		        c++;
		    }
		}
		for(int i = 1; i <= n-1; i++){
		    result += cnt[i];
		}
		
		
		// 出力
		System.out.println(result);
		
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}

}


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

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

    char c[6];
    for(int i = 0; i < 6; ++i){
        c[i] = s[i];
    }

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

Measured memory_bytes: 256
s = input()
n = len(s)
ans = 0

for i in range(2**(n-1)):
  form = s
  bit = []
  for _ in range(n-1):
    bit.append(i%2)
    i =  i//2

  for j in range(n-1):
    if bit[j]:
      form = form[:n-j-1] + '+' + form[n-j-1:]

    
  ans += eval(form)
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

const int MOD = 1000000007;
int bin_pow_mod(int a, int b) {
    int ret = 1;
    while (b > 0) {
        if (b & 1) ret = (ret * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return ret;
}

signed main() {
    string s;
    cin >> s;
    int n = SZ(s);
    vi al(n), ql(n), qr(n), cr(n);
    REP(i, n) {
        if (s[i] == 'A') al[i]++;
        if (s[i] == '?') ql[i]++;
        if (i > 0) {
            al[i] += al[i - 1];
            ql[i] += ql[i - 1];
        }
    }
    REPR(i, n - 1) {
        if (s[i] == 'C') cr[i]++;
        if (s[i] == '?') qr[i]++;
        if (i < n - 1) {
            cr[i] += cr[i + 1];
            qr[i] += qr[i + 1];
        }
    }
    int ans = 0;
    auto f = [&](int L, int R, int A, int C) {
        int r1 = bin_pow_mod(3, L) * A % MOD;
        if (L > 0) {
            r1 += L * bin_pow_mod(3, L - 1) % MOD;
            r1 %= MOD;
        }
        int r2 = bin_pow_mod(3, R) * C % MOD;
        if (R > 0) {
            r2 += R * bin_pow_mod(3, R - 1) % MOD;
            r2 %= MOD;
        }
        return r1 * r2 % MOD;
    };
    REP(i, n) {
        if (s[i] == 'B') {
            int L = ql[i], R = qr[i];
            int A = al[i], C = cr[i];
            ans += f(L, R, A, C);
            ans %= MOD;
        }
        if (s[i] == '?') {
            int L = ql[i] - 1, R = qr[i] - 1;
            int A = al[i], C = cr[i];
            ans += f(L, R, A, C);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3664
s = [""]+list(input())
t = [""]+list(input())
dp = [[0 for x in range(len(s))] for x in range(len(t))]
for y in range(1,len(t)):
    for x in range(1,len(s)):
        if(t[y] == s[x]):
            dp[y][x] = dp[y-1][x-1]+1
        else:
            dp[y][x] = max(dp[y-1][x],dp[y][x-1])
y,x = len(t)-1,len(s)-1
ans = []
while(dp[y][x] > 0):
    if(dp[y][x] == dp[y-1][x]):
        y -= 1
    elif(dp[y][x] == dp[y][x-1]):
        x -= 1
    else:
        ans.append(s[x])
        y -= 1
        x -= 1
ans.reverse()
print("".join(ans))


Measured memory_bytes: 123484
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int s2i(string str){
  istringstream ss(str);
  int n;
  ss >> n;
  return n;
}
int main(){
  int n;
  cin >> n;
  int i,j,k;
  string str;
  while(n!=0){
    int b,c;
    int f=0;
    int o=0;
    int xmin=-1000000010,xmax=1000000010;
    cin >> str;
    if(str=="x"){
      f=1;
    }else{
      b=s2i(str);
    }
    for(i=1;i<n;i++){
      cin >> str;
      if(str=="x"){
	if(f==1) o=1;
	else {
	  if(i%2==0){
	    xmax=min(xmax,b-1);
	  }else{
	    xmin=max(xmin,b+1);
	  }
	  f=1;
	}
      }else{
	c=s2i(str);
	if(f==0){
	  if(i%2==0){
	    if(b<=c) o=1;
	  }else{
	    if(b>=c) o=1;
	  }
	  b=c;
	}else{
	  if(i%2==1){
	    xmax=min(xmax,c-1);
	  }else{
	    xmin=max(xmin,c+1);
	  }
	  f=0;
	  b=c;
	}
      }
    }
    //cout << xmax << ":" << xmin << endl;
    if(o==1){
      cout << "none" << endl;
    }else if(xmax-xmin>0){
      cout << "ambiguous" << endl;
    }else if(xmax-xmin==0){
      cout << xmax << endl;
    }else{
      cout << "none" << endl;
    }
    cin >> n;
  }
  return 0;
}

Measured memory_bytes: 1220
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# GCD
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

def main():
  n=I()
  l=LI()

  l1=[l[0]]
  for i in range(1,n):
    l1.append(gcd(l1[i-1],l[i]))

  l2=[l[-1]]
  for i in range(1,n):
    l2.append(gcd(l2[i-1],l[n-i-1]))
  l2.reverse()

  mx=max(l1[-2],l2[1])
  for i in range(n-2):
    mx=max(mx,gcd(l1[i],l2[i+2]))

  return mx

print(main())


Measured memory_bytes: 16936
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	var min int
	var max int
	for i := 0; i < n; i++ {
		a := nextInt()
		if i == 0 {
			min = a
			max = a
			continue
		}
		if a < min {
			min = a
		}
		if a > max {
			max = a
		}
	}
	fmt.Println(max - min)
}


Measured memory_bytes: 640
#include<stdio.h>

int BinarySearch(int ,int ,int *);

int main(){
  int n,q;
  scanf("%d",&n);
  int i,S[n];
  for(i=0;i<n;i++)scanf("%d",&S[i]);
  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++)scanf("%d",&T[i]);
  int cnt=0;
  for(i=0;i<q;i++)cnt+=BinarySearch(n,T[i],&S[0]);
  printf("%d\n",cnt);
  return 0;
}

int BinarySearch(int n,int key,int *x){
  int left=0,right=n,mid;
  while(right>left){
    mid=(left+right)/2;
    if(key==x[mid])return 1;
    if(key>x[mid])left=mid+1;
    else if(key<x[mid])right=mid;
  }
  return 0;
}




Measured memory_bytes: 2316
Sx, Sy, Tx, Ty = map(int, input().split())

for i in range(2):
    print("L"*i, end="")
    print("U"*((Ty-Sy)+i), end="")
    print("R"*((Tx-Sx)+i), end="")
    print("D"*i, end="")
    print("R"*i, end="")
    print("D"*((Ty-Sy)+i), end="")
    print("L"*((Tx-Sx)+i), end="")
    print("U"*i, end="")

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

int main()
{
	int n; cin >> n;
	
	vector<int> a(n), b(n), c(n - 1);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n - 1; i++) cin >> c[i];

	int ans = 0;
	for (int i = 0; i < n; i++) ans += b[i];
	
	for (int i = 0; i < n - 1; i++) {
		if (a[i + 1] - a[i] == 1) {
			ans += c[a[i] - 1];
		}
	}

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

Measured memory_bytes: 256
n = int(input())
sk = int((2*n)**0.5)
km = sk + 1
if (n !=sk*km//2):
  print ("No")
else:
  print ("Yes")
  print (km)
  li = [[] for i in range(km)]
  #print (li)
  c = 1
  for i in range(sk):
      for j in range(1+i,sk+1):
          li[i].append(c)
          li[j].append(c)
          c+=1
  [ print ( str(sk)+" "+" ".join([ str(_p) for _p in it ]) )   for it in li]
  #print (li)

Measured memory_bytes: 9972
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std ;
using ll = long long ;
using vll = vector<ll> ;
using pll = pair<ll,ll> ;
using vpll = vector<pll> ;
using vb = vector<bool> ;

vpll xd ;
ll n ;
ll mod = 998244353 ;
ll ok = 0 ;

ll cnt(ll i,vb &check,vll &num){
	if(!check.at(i)) return 1 ;
	check.at(i) = false ; ok++ ;
	if(i==n-1){
		num.at(i) = 2 ;
		return 2 ;
	}
	if(xd.at(i+1).first>=xd.at(i).first+xd.at(i).second){
		num.at(i) = 2 ;
		return 2 ;
	}
	ll j = i+1 ;
	ll res = 1 ;
	while(xd.at(i).first+xd.at(i).second>xd.at(j).first&&ok!=n){
		res = res*cnt(j,check,num)%mod ;
		j++ ;
		if(j==n) break ;
	}
	num.at(i) = res+1 ;
	return res+1 ;
}

int main(){
	cin >> n ;
	pll sub ;
	ll ans = 1 ;
	vb check(n,true) ;
	vll num(n,-1) ;
	for(int i=0;i<n;i++){
		cin >> sub.first >> sub.second ;
		xd.push_back(sub) ;
	}
	sort(xd.begin(),xd.end()) ;
	for(ll i=0;i<n;i++){
		if(check.at(i)) ans = ans*cnt(i,check,num)%mod ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 21488
#include <stdio.h>
int main(){
  int a,b,c,ans;
  scanf("%d %d %d",&a,&b,&c);
  if(a == b){
    ans = c;
  }else if(b == c){
    ans = a;
  }else{
    ans = b;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> p(n),q(n),x(n);
	rep(i,n) cin>>p[i];
	rep(i,n) cin>>q[i];
	rep(i,n) x[i]=i+1;
	int a=-1,b=-1,cnt=0;
	do{
		if(a!=-1 && b!=-1) break;
		cnt++;
		if(a==-1){
			bool flag=true;
			rep(i,n){
				if(p[i]!=x[i]){
					flag=false;
					break;
				}
			}
			if(flag) a=cnt;
		}
		if(b==-1){
			bool flag=true;
			rep(i,n){
				if(q[i]!=x[i]){
					flag=false;
					break;
				}
			}
			if(flag) b=cnt;
		}
	}while(next_permutation(begin(x),end(x)));
	cout<<abs(a-b)<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 100000000;
    for(int k = -100; k < 101; k++){
        int cost = 0;
        for(int j = 0; j < n; j++){
            cost += (k-a[j])*(k-a[j]);
        }
        ans = min(ans,cost);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N; cin >> N;
    int p[N];
    rep(i, N) cin >> p[i]; 

    int min_v = 999999999;
    int count=0;
    rep(i, N){
        if(min_v >= p[i]){
            min_v = p[i];
        }else{
            count++;
        }
    }

    cout << N-count << endl; 
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back

typedef long long int ll;

using namespace std;




int main()
{
    si(n);

    ll ans=0;
    
    for(int i=1;i<n;i++)
    {
        ll val=floor((n-1)/i); 
        ans+=val;
    }
    cout<<ans;
    
}

Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int n;
string str;
int main()
{
	cin >> n;
	cin >> str;
	int ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (i != 0 && str[i] != str[i - 1])
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <cassert>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const uint64_t MAXN = 501;
//#define EVAL
//#define DEBUG
#ifdef EVAL
ifstream in("input.txt");
ofstream out("output.txt");
#else
istream &in(cin);
ostream &out(cout);
#endif

uint64_t c_max;
uint64_t n_ogg;



int main(void) {
	// Ottieni c_max e n_ogg
	in >> n_ogg;
	in >> c_max;
	
	// Crea un vettore di paia di uint64_teri peso valore std::pair
	vector<std::pair<uint64_t, uint64_t>> oggetti;
	// Inserisci gli oggetti
	{
		uint64_t peso;
		uint64_t valore;
		for (uint64_t i = 0; i < n_ogg; i++)
		{
			in >> peso;
			in >> valore;
			oggetti.push_back(std::pair<uint64_t, uint64_t>(peso, valore));
		}
	}
	// Crea una matrice larga quanto la capacità massima (c_max) e lunga 2 (Soluzione precedente e soluzione corrente)
	vector<uint64_t> riga1; // Verranno scambiati opportunatamente
	vector<uint64_t> riga2;
	for (uint64_t i = 0; i < c_max+1; i++) // Inizializza la prima riga a 0
	{
		riga1.push_back(0);
		riga2.push_back(0); // Nel dubbio, facciamo anche la seconda riga, per adattare la dimensione
	}
	vector<uint64_t>* prev =&riga1;
	vector<uint64_t>* curr =&riga2;
	vector<uint64_t>* tmp = nullptr;
	for (uint64_t i = 0; i < n_ogg; i++) // Per ogni oggetto fino ad n_ogg
	{


		for (uint64_t cell = 0; cell < c_max+1; cell++) // Incrementando le celle della  capacità dello zaino c_max
		{

			if (oggetti[i].first > cell)// Se NON posso mettere l'oggetto nello zaino
			{
				(*curr)[cell] = (*prev)[cell];// Prendi la soluzione precedente, equivalente al valore della riga sopra
			}
			// Altrimenti se mi conviene prendere l'oggetto, ovvero:
			else {
				uint64_t takeval = oggetti[i].second + (*prev)[cell - oggetti[i].first];
				if ((*prev)[cell] < takeval) { // Se la soluzione precedente è minore dell'oggetto + il miglior guadagno dello spazio che mi rimane
					(*curr)[cell] = takeval;  // Imposta il valore eguale al valore dell'oggetto+ guadagno dello spazio che mi rimane
				}
				else { // Altrimenti, prendo la soluz precedente
					(*curr)[cell] = (*prev)[cell];
				}
			}
			
		}

		#ifdef DEBUG
		for (uint64_t i = 0; i < c_max + 1; i++)
		{
			cout << (*curr)[i] << "\t";
		}
		cout << "\n";
		#endif // DEBUG

		
		// Inverti puntatori prev e curr 

		tmp = prev;
		prev = curr;
		curr = tmp;

	}

	uint64_t max = (*prev)[0]; // Ottieni della riga
	for (uint64_t i = 1; i < c_max+1; i++)
	{
		if ((*prev)[i] > max) {
			max = (*prev)[i];
		}
	}
	#ifdef DEBUG
		cout << "\nSoluz: " << max << "\n";
	#endif // DEBUG



	#ifdef DEBUG
	for (std::pair<uint64_t, uint64_t> i : oggetti) { // Debug: Stampa oggetti
		cout <<"Peso: " << i.first << " Valore: " << i.second <<"\n";
	}
	#endif
	out << max;
	#ifdef DEBUG
	system("PAUSE");
	#endif // DEBUG
	return 0;
}


Measured memory_bytes: 2036
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
    double x1,x2,x3,y1,y2,y3,xp,yp;
    double calc1,calc2,calc3;
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
        calc1 = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
        calc2 = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
        calc3 = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
        if((calc1>0&&calc2>0&&calc3>0) || (calc1<0&&calc2<0&&calc3<0)){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2692
s = int(input())
def f(x):
  if x % 2 == 0:
    return x/2
  else:
    return 3 * x + 1

X = [s]
m = 1
next = s

while True:
  m += 1
  next = f(next)
  if next in X:
    break
  else:
    X.append(next)
    
print(m)


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

#define ORZ_EVERYBODY

map<int, int> mp;
int res[(size_t)1e5 + 5];

int main() {
    int n, a, cnt = 0;
    long long mx = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        mp[-a]++;
    }
    for (auto it = mp.begin(); it != mp.end(); it++) {
        const auto& x = *it;
        for (int i = 1; i * 2 <= x.second; i++) res[cnt++] = x.first;
    }
    for (int i = 0; i + 1 < cnt; i++)
        mx = max(mx, (long long)res[i] * (long long)res[i + 1]);
    cout << mx;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vb> vmb;
typedef vector<vi> vmi;
typedef vector<vll> vmll;

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

    vi wei(n), val(n);
    for (int i = 0; i < n; ++i)
        cin >> wei[i] >> val[i];

    vmll dp(n + 1, vll(w + 1, 0));
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= wei[i - 1])
                dp[i][j] = max(dp[i][j], val[i - 1] + dp[i - 1][j - wei[i - 1]]);
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const ll MOD = 1000000007;

const double PI = 3.1415926535897932;
/******define variable start******/
ll k, x;
/*******define variable end*******/
ll solve(){
    cin >> k >> x;
    if(k*500 >= x){
        cout << "Yes" << endl;
    }else{
        cout <<"No"<<endl;
    }
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}

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

int main(){
  int n;
  string c;
  cin >> n >> c;
  int r=0;
  for(int i=0; i<n; i++){
    if(c[i]=='R')r++;
  }
  int ret=0;
  for(int i=0; i<r; i++){
    if(c[i]=='W')ret++;
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 3388
#include <iostream>
#include <string>

using namespace std;

bool istenpower(int x){
    while(x % 10 == 0)
        x /= 10;
    return x == 1;

}
int ketasum(int x){
    int ret = 0;
    while(x > 0){
        ret += x % 10;
        x /= 10;
    }
    return ret;

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

    if(istenpower(n)){
        cout << 10 << endl;
    }
    else{
        cout << ketasum(n) << endl;
    }
    return 0;
}


Measured memory_bytes: 256