akhauriyash/Code-Regression huggingface dataset:
//#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;}

const long long INF = 1e18;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    vector <array <long long, 2>> dp(n + 1, {-INF, -INF});
    dp[0][0] = 0;
    forn (i, 0, n) {
        if (a[i] > 0) {
            if (a[i] % 2) {
                chkmax(dp[i + 1][0], dp[i][0] + a[i] / 2);
                chkmax(dp[i + 1][0], dp[i][1] + a[i] / 2 + 1);
                chkmax(dp[i + 1][1], dp[i][0] + a[i] / 2);
                chkmax(dp[i + 1][1], dp[i][1] + a[i] / 2);
            } else {
                chkmax(dp[i + 1][0], dp[i][0] + a[i] / 2);
                chkmax(dp[i + 1][0], dp[i][1] + (a[i] - 1) / 2 + 1);
                chkmax(dp[i + 1][1], dp[i][0] + (a[i] - 1) / 2);
                chkmax(dp[i + 1][1], dp[i][1] + (a[i] - 1) / 2 + 1);

            }
        } else {
            dp[i + 1][0] = max(dp[i][0], dp[i][1]);
        }
    }
    cout << *max_element(all(dp[n]));
    return 0;
}

Measured memory_bytes: 5292
import numpy as np
import itertools

N=int(input())

X=[]
Y=[]
for i in range(N):
    XY=input().split(" ")
    X.append(float(XY[0]))
    Y.append(float(XY[1]))

def get_dist(x1,y1,x2,y2):
    return np.sqrt(pow(x2-x1,2)+pow(y2-y1,2))

seq=range(1,N+1)
p=list(itertools.permutations(seq))

totals=[]
for i in range(len(p)):
    route=list(p[i])
    S=0
    for k in range(len(route)-1):
        S+=get_dist(X[route[k]-1],Y[route[k]-1],X[route[k+1]-1],Y[route[k+1]-1])
    totals.append(S)

print(np.average(totals))

Measured memory_bytes: 19864
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 500
int V;
vector<int> G[MAX_V],rG[MAX_V],vs,vG[MAX_V];
bool used[MAX_V];
int cmp[MAX_V];
void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}
void dfs(int v){
  used[v]=1;
  for(int i=0;i<G[v].size();i++){
    if(!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}
void rdfs(int v,int k){
  used[v]=1;
  cmp[v]=k;
  vG[k].push_back(v);
  for(int i=0;i<rG[v].size();i++){
    if(!used[rG[v][i]]) rdfs(rG[v][i],k);
  }
}
int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++){
    if(!used[v]) dfs(v);
  }
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--){
    if(!used[vs[i]]) rdfs(vs[i],k++);
  }
  return k;
}
int main(){
  while(cin>>V,V){
    int i,j,k,l;
    for(i=0;i<MAX_V;i++) G[i].clear(),rG[i].clear(),vG[i].clear();
    double p[V];
    for(i=0;i<V;i++){
      cin>>p[i]>>k;
      for(j=0;j<k;j++){
	cin>>l;
	add_edge(i,l-1);
      }
    }
    k=scc();
    double ans=1.0,res;
    for(i=0;i<k;i++){
      bool f=1;
      res = 1.0;
      for(j=0;j<vG[i].size();j++){
	res*=p[vG[i][j]];
	for(l=0;l<rG[vG[i][j]].size();l++)
	  f&=(cmp[vG[i][j]]==cmp[rG[vG[i][j]][l]]);
      }
      if(f) ans*=(1.0-res);
    }
    printf("%.10lf\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e5;  
using  p = pair<int,int>;

int main(){
 int n;
 cin >> n;
 auto a = vector<ll>(n,0);
 for (int i = 0; i < n; i++)
 {
   cin >> a[i];
 }

  auto b = vector<ll>(n,0);
  for (int i = 0; i < n; i++)
  {
    b[i]= a[i] -(i+1);
  }

  sort(b.begin(),b.end());
  ll half = b[n/2];
   ll ans =0;
  for(int i=0;i<n;i++){
  	ans += abs(b[i]-half);
  }
  
  cout << ans << endl;

}
  
  

Measured memory_bytes: 3328
import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		
		int cnt = 1;
		for (int i = 1; i < n; i++) {
			if (s[i-1] != s[i])
				cnt++;
		}
		
		System.out.println(cnt);
	}
}


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

int main() {
	string s;
	cin >> s;
	int m = 700;
	for(int i = 0;i < 3;i++){
		if(s.at(i) == 'o'){
			m += 100;
		}
	}
	cout << m << endl;
}

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


namespace Test1 {





    class ClassMain {


        public static bool isA(string str) {
            char[] chrs = str.ToCharArray();
            int phase = 0;
            int count = 0;
            if(chrs.Length<6){return false;}
            for (int i = 0; i < chrs.Length; i++) {
                if (phase == 0) {
                    if (chrs[0] != '>' || chrs[1] != '\'') { return false; }
                    i++;
                    phase = 1;
                }
                else if (phase == 1) {
                    if (chrs[i] == '#') {
                        if (count == 0) { return false; }
                        else {
                            phase = 2;
                            continue;
                        }
                    }
                    if (chrs[i] != '=') { return false; }
                    else { count++; }
                }
                else if (phase == 2) {
                    if (chrs[i] != '=') { return false; }
                    else { 
                        count--;
                        if (count == 0) { phase = 3; }
                    }
                }
                else if (phase == 3) {
                    if (chrs[i] == '~' && i == chrs.Length - 1) { return true; }
                    else { return false; }
                }
            }
            return false;
        }

        public static bool isB(string str) {
            char[] chrs = str.ToCharArray();
            int phase = 0;
            int count = 0;
            if (chrs.Length < 6) { return false; }
            for (int i = 0; i < chrs.Length; i++) {
                if (phase == 0) {
                    if (chrs[0] != '>' || chrs[1] != '^') { return false; }
                    i++;
                    phase = 1;
                }
                else if (phase == 1) {
                    if (chrs[i] == 'Q'&&chrs[i+1]=='=') {
                        count++;
                        i++;
                        continue;
                    }
                    if (chrs[i] == '~'&&chrs[i+1]=='~') { 
                        return (count>0); 
                    }
                    else { return false; }
                }
            }
            return false;
        }

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }
                for (int i = 0; i < n; i++) {
                    line = Console.ReadLine();
                    if (isA(line)) { Console.WriteLine("A"); }
                    else if (isB(line)) { Console.WriteLine("B"); }
                    else { Console.WriteLine("NA"); }
                }
                break;


            }
        }
    
    }



    
}

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

int main(){
    int N, cnt = 0;
    int Seat[100000] = {0};
    cin >> N;
    int l[N] = {0}, r[N] = {0};
    for (int i = 0; i < N; i++){
        cin >> l[i] >> r[i];
    }

    for(int i = 0; i < N; i++){
        for(int j = l[i] - 1; j < r[i]; j++){
            Seat[j] = 1;
        }
    }

    for(int i = 0; i < 100000; i++){
        if (Seat[i] == 1) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <utility>
#include <ctime>
#include <cassert>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii > vii;
typedef vector<pair<int, pair<int, int> > > viii;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<vii> vvii;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define MEM(a,b) memset(a,(b),sizeof(a))
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(a) a.begin(),a.end()
#define loop(x,a,b) for(int (x) = (a);(x)<(b);(x)++)
#define rep(x,n)   for(int (x)=0;(x)<(n);(x)++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ain(a,n) int ((a)[(n)]); for(int i=0; i<(n); i++) cin>>((a)[i])  
#define md 1000000007
#define MAXN 200005

int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n],b[n];
    rep(i,n)
    	cin>>a[i]>>b[i];
    vi com;
    rep(i,n)
    {
    	com.pb(a[i]);
    	com.pb(b[i]);
    }
    sort(all(com));
    int mid = com[n-1];
    int flag = 0;
    rep(i,n)
    	if(max(a[i],b[i]) <= mid)
    		flag = 1;
    int cnt = 0;
    rep(i,n) {
    	if(a[i] > b[i])
    		cnt ++;
    }
    if(cnt == 0 or cnt == n)
    	flag = 1;
    ll ans = 0;
    rep(i,n)
    	ans += com[i];
    if(flag == 0){
    	int fg = 0;
    	rep(i,n)
    	{
    		if(min(a[i],b[i]) == com[n-1] and max(a[i],b[i]) == com[n])
    			fg = 1;
    	}
    	if(fg == 0)
    		ans += com[n]-com[n-1];
    	else 
    		ans += min(com[n]-com[n-2], com[n+1] -com[n-1]);
    }

   	cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 2168
# https://scrapbox.io/ganariya/AtCoderDP%E3%81%BE%E3%81%A8%E3%82%81%E3%82%B3%E3%83%B3%E3%83%86%E3%82%B9%E3%83%88_L%E5%95%8F%E9%A1%8C_%E3%80%8CDeque%E3%80%8D

from collections import deque
N = int(input())
a = deque(list(map(int,input().split())))
#区間dp
#dp[i][j] : [i,j)番目の要素が残っている状態からの最適解

def Sente(i,j):
    return True if (N-(j-i))%2 == 0 else False

dp = [[0]*(N+1) for _ in range(N+1)]
for i in reversed(range(N)):
    for j in range(i+1,N+1):
        if Sente(i,j):
            dp[i][j] = max(a[i] + dp[i+1][j], a[j-1] + dp[i][j-1])
        else:
            dp[i][j] = min(-a[i] + dp[i+1][j], -a[j-1] + dp[i][j-1])
print(dp[0][N])


Measured memory_bytes: 112988
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
#define ll long long 
#define d double
using namespace std;

int main()
{
	int n,m;
	cin>>n>>m;
	int a[n],b[m];
	int i;
	int j;
	int c1=2;
	int c2=1;
	for(i=0;i<n;i++){
		a[i]=c1;
		c1+=2;
	}
	
	for(i=0;i<m;i++){
		b[i]=c2;
		c2+=2;
	}
	
	int s;
	int count=0;
	for(i=0;i<n;i++){
		s=0;
		for(j=i+1;j<n;j++){
		   s=s+a[i]+a[j];
		   if(s%2==0){
		   	 count++;
		   }
		}
	}
	
	int count2=0;
	for(i=0;i<m;i++){
		s=0;
		for(j=i+1;j<m;j++){
			s=s+b[i]+b[j];
			if(s%2==0){
				count2++;
			}
		}
	}
	
    cout<<count+count2<<endl;
    return 0;
	
}

Measured memory_bytes: 3596
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if AbsDiff(n, m) > 1 {
		fmt.Println(0)
		return
	}
	if n != m {
		fmt.Println(Factorial(n) * Factorial(m) % Mod)
	} else {
		fmt.Println(Factorial(n) * Factorial(m) * 2 % Mod)
	}
}

const Mod = 1000000007

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func Factorial(n int) int {
	if n == 0 {
		return 0
	}
	num := 1
	for i := 2; i <= n; i++ {
		num = num * i % Mod
	}
	return num
}

func AbsDiff(n1 int, n2 int) int {
	return int(math.Abs(float64(n1 - n2)))
}


Measured memory_bytes: 1836
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int x, n, p[N], ans = mod, pos = -mod;
bool used[N];

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> x >> n;
   for (int i = 1; i <= n; i ++) {
      cin >> p[i];
      used[p[i]] = 1;
   }    
   for (int i = -200; i <= 200; i ++) {
      if (i < 0 || !used[i]) {
         if (ans > abs (x - i)) {
            ans = abs (x - i);
            pos = i;
         }
      }   
   }
   cout << pos;
}               
 
signed main () {                                       
   //#ifdef QWERTY
   //   freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

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

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

#[fastout]
fn main() {
    input!{
        n: Chars,
    }
    let mut abc:Vec<char> = vec!['A','B','C'];
    abc.extend(n);
    for i in abc {
        print!("{}", i);
    }    
    print!("\n");
}


Measured memory_bytes: 2144
#include <stdio.h>

int main(void)
{
    char s[4];
    int i,a = 0,b = 0;
    scanf("%s", &s);

    for (i = 0; i < 3; i++)
    {
        if (s[i] == 'A') a++;
        else b++;
    }

    if (a == 2 && b == 1 || a == 1 && b == 2) printf("Yes");
    else printf("No");
    
    return 0;
}

Measured memory_bytes: 1688
#include <stdio.h>
#include <cstring>
int main ()
{
	int i;
	char s[101];
	scanf("%s",&s);
	for(i=0;i<strlen(s);i++)
	{
		if(s[i]=='L')
		{
			printf("No");
			return 0;
		}
		i++;
		if(s[i]=='R')
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k, q; cin >> n >> k >> q;
  vector<int> cnt(n, 0);
  REP(_, q) {
    int a; cin >> a; --a;
    ++cnt[a];
  }
  REP(i, n) {
    int score = k - (q - cnt[i]);
    cout << (score <= 0 ? "No\n" : "Yes\n");
  }
  return 0;
}


Measured memory_bytes: 1024
k, n = list(map(int, input().split()))
A = list(map(int, input().split()))

max_d = 0
for i in range(n):
    if i == 0:
        d = A[i] + (k - A[-1])
    else:
        d = A[i] - A[i-1]

    if d > max_d:
        max_d = d

print(k-max_d)


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

int main() {
  int N;
  cin >> N;
  
  std::map<int, int> m;
  for (int i = 1; i <= N; ++i) {
    int A;
    cin >> A;
    m[A] = i;
  }
  
  for (int i = 1; i <= N; ++i) {
    if (i > 1) cout << " ";
    cout << m[i];
  }
  cout << endl;
}
  


Measured memory_bytes: 5504
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){

  long long int n,p;
  cin>>n;
  cin>>p;
  vector<long long int> prime(1000001,1);
  prime[0]=0;
  prime[1]=0;

  vector<long long int>pp(0);

  long long int ans=1;

  //cout << (long long int)pow(10,12) << endl;
  if(n==1){
    cout << p << endl;
    return 0;
  }

  for(int i=2;i<=1000000;i++){
      if(!prime[i] ) continue;
      else{
        for(int j=2;i*j<=1000000;j++){
          prime[i*j]=0;
        }
      }

  }
  for(int i=2;i<=1000000;i++){
    if(prime[i] ) pp.push_back(i);
  }
  for(int i=0;i<pp.size();i++){
    long long int cnt=0;
    while(p%pp[i]==0 && p>=pp[i]){
      cnt++;
      p=p/pp[i];
    }
    //cout << pp[i] << " ";
    //cout << "cnt:" << cnt << endl;
    /*
    if(cnt >= 1){
      //cout << pp[i] << " ";
      //cout << "cnt:" << cnt << endl;
      ans*=(long long int)(pow(pp[i],cnt/n));
    }
    */
    for(int j=0;j<(cnt/n);j++){
      ans*=pp[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define co(A) cout<<A<<endl
#define cosp(A) cout<<A<<" "
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int n;
	cin >> n;
	vector<ll> a(n);
	ll x = 0;
	rep(i, 0, n) {
		cin >> a[i];
		x ^= a[i];
	}
	rep(i, 0, n) {
		cout << (x^a[i]);
		if (i != n - 1)cout << " ";
	}
	cout << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 4776
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}


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



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
    vi prime;
    prime.push_back(2);
    rep(i,3,55555){
        bool flag=true;
        rep(j,0,prime.size()){
            if(i%prime[j]==0)flag=false;
        }
        if(flag)prime.push_back(i);
    }
    vi ans;
    rep(i,0,prime.size())if(prime[i]%5==1)ans.push_back(prime[i]);
    int n;cin>>n;
    cout<<ans[0];
    rep(i,1,n)cout<<" "<<ans[i];
    cout<<endl;
	return 0;
}



Measured memory_bytes: 256
//#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);
    vector <int> a(5);
    cin >> a;
    forn (i, 0, 5)
        if (!a[i])
            return cout << i + 1, 0;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=1,mod=1e9+7;
  cin >> n;
  long long a[n];
  map<long long, int> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  if(n%2==0){
    for(int i=1;i<n;i+=2){
      if(mp[i]!=2){
        cout << 0 << endl;
        return 0;
      }else{
        ans*=2;
        ans%=mod;
      }
    }
  }else{
    for(int i=0;i<n;i+=2){
      if(i==0){
        if(mp[i]!=1){
          cout << 0 << endl;
          return 0;
        }
      }else{
        if(mp[i]!=2){
          cout << 0 << endl;
          return 0;
        }else{
          ans*=2;
          ans%=mod;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    //
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// =========

fn csum(n: f64) -> f64 {
    n * (n + 1.0) / 2.0
}

fn main() {
    input! {
        n: usize,
        k: usize,
        p: [f64;n]
    }
    let p: Vec<f64> = p.iter().map(|e| csum(*e) / *e).collect();
    let mut tmpans = {
        let mut t = 0.0;
        for i in 0..k {
            t += p[i];
        }
        t
    };
    let mut ans = tmpans;
    for i in k..n {
        tmpans -= p[i - k];
        tmpans += p[i];
        ans = ans.max(tmpans);
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 8444
n = int(input())
r=[list(map(int, input().split())) for i in range(n)]
b=[list(map(int, input().split())) for i in range(n)]
b.sort(key=lambda x:x[0])
p=[]
r_used=[0]*n
for i in range(n):
    q=[]
    for j in range(n):
        if r[j][0]<b[i][0] and r[j][1]<b[i][1]:
            q.append([r[j][1],j])
    q.sort(key=lambda x:x[0],reverse=True)
    p.append(q)
ans = 0
for i in range(n):
    for j in range(len(p[i])):
        if p[i][j][0]<b[i][1] and r_used[p[i][j][1]]==0:
            ans+=1
            r_used[p[i][j][1]]=1
            break
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;

#define MOD 1000000007

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

    int N;
    cin >> N;

    map<string, int> a;

    for(int i = 0; i < N; i++) {
        string s;
        cin >> s;
        a[s]++;
    }

    cout << "AC x " << a["AC"] << endl;
    cout << "WA x " << a["WA"] << endl;
    cout << "TLE x " << a["TLE"] << endl;
    cout << "RE x " << a["RE"] << endl;
}

Measured memory_bytes: 3664
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, K) = nextIntList()
    val S = next().replace(" ", "").toCharArray().asIterable()
    var ans = N
    while (ans.toString().toCharArray().any { S.contains(it) }) {
        ans++
    }
    println(ans)
}

Measured memory_bytes: 38384
// 2011/08/25 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		char G[257][257];
		for(int i=0; i<=n+1; i++)
			for(int j=0; j<=n+1; j++)
				G[i][j] = '0';

		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++)
				cin >> G[i][j];

		int max = 0;
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				if(G[i][j]=='0')
					continue;

				int cnt = 1;
				int I = i;
				int J = j;
				while(G[I][J-1]=='1'){
					cnt++;
					J--;
				}
				I = i;
				J = j;
				while(G[I][J+1]=='1'){
					cnt++;
					J++;
				}
				if(max<cnt)
					max = cnt;


				cnt = 1;
				I = i;
				J = j;
				while(G[I-1][J]=='1'){
					cnt++;
					I--;
				}
				I = i;
				J = j;
				while(G[I+1][J]=='1'){
					cnt++;
					I++;
				}
				if(max<cnt)
					max = cnt;

				cnt = 1;
				I = i;
				J = j;
				while(G[I-1][J-1]=='1'){
					cnt++;
					I--;
					J--;
				}
				I = i;
				J = j;
				while(G[I+1][J+1]=='1'){
					cnt++;
					I++;
					J++;
				}
				if(max<cnt)
					max = cnt;

				cnt = 1;
				I = i;
				J = j;
				while(G[I-1][J+1]=='1'){
					cnt++;
					I--;
					J++;
				}
				I = i;
				J = j;
				while(G[I+1][J-1]=='1'){
					cnt++;
					I++;
					J--;
				}
				if(max<cnt)
					max = cnt;
			}
		}

		cout << max << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    for(int i = 0; i < n; i++) {
        cin >> w[i];
    }
    int ans = 1e9;
    for(int i = 0; i < n; i++) {
        int l = 0, r = 0;
        for(int j = 0; j < i; j++) {
            l += w[j];
        }
        for(int j = i; j < n; j++) {
            r += w[j];
        }
        ans = min(ans, abs(l-r));
    }

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> ac(n), pena(n);
    for(ll i = 0; i<m; i++){
        ll p;
        string s;
        cin>>p>>s;
        --p;
        if(ac[p])continue;
        if(s == "AC"){
            ac[p] = 1;
        }
        else {
            pena[p]++;
        }
    }
    ll AC = 0, PENA = 0;
    for(ll i = 0; i<n; i++){
        AC += ac[i];
        if(ac[i])PENA += pena[i];
    }
    cout<<AC<<" "<<PENA<<endl;
    return 0;
}



Measured memory_bytes: 1792
from collections import Counter


def main():
    n = int(input())
    arr = list(map(int, input().split()))

    cnt = Counter(arr)
    total = 0
    for key in cnt.keys():
        total += cnt[key]*(cnt[key]-1)//2

    for i in range(n):
        tmp = total
        tmp -= cnt[arr[i]]*(cnt[arr[i]]-1)//2
        tmp += (cnt[arr[i]]-1)*(cnt[arr[i]]-2)//2
        print(tmp)


if __name__ == "__main__":
    main()


Measured memory_bytes: 26772
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    string s1, s2, s3; cin >> s1 >> s2 >> s3;

    queue<char> a,b,c;
    for(auto x:s1) a.push(x);
    for(auto x:s2) b.push(x);
    for(auto x:s3) c.push(x);

    char car = a.front(); a.pop();
    while (1){
        if(car == 'a'){if(a.empty()){ put('A'); break;}car = a.front(); a.pop(); }
        else if(car == 'b'){ if(b.empty()){ put('B'); break; } car = b.front(); b.pop();}
        else if(car == 'c') {if(c.empty()){ put('C');  break; } car = c.front(); c.pop(); }
    }
}

Measured memory_bytes: 3608
//Distinct or Not

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    set<int>m;
    rep(i,0,n){
        if(!m.insert(a[i]).second){
            cout<<"NO"<<nnn;
            return 0;
        }
    }
    cout<<"YES"<<nnn;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  rep(i, 10) rep(j, 10) {
    if (n == i*j) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

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

int main() {
  ll n;
  cin >> n;
  int ori = n;
  int sum = 0;
  while (n != 0) {
    sum += n % 10;
    n /= 10;
  }
  if (ori % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<climits>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
#define MAXN 10
char s[MAXN+5];
int wei[MAXN+5],len;
long long ans;
void dfs(int i,long long num,long long X)
{
    if(i>len)
    {
        if(num)X+=num;
        //printf("%lld\n",X);
        ans+=X;
        return ;
    }
    dfs(i+1,num*10+wei[i],X);
    dfs(i+1,0,X+num*10+wei[i]);
}
int main()
{
    scanf("%s",s+1);
    len=strlen(s+1);
    for(int i=1;i<=len;i++)wei[i]=s[i]-'0';
    dfs(1,0,0);
    printf("%lld",ans/2);
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}

ll X, Y;
ll i, j, k;
ll Fa[10101010];


int main(){
    scanf("%lld%lld", &X,&Y);
    Fa[0] = 1;
    fornum(i,0,1010101){
        Fa[i + 1] = Fa[i] * (i + 1) % MOD;
    }
    if(X>Y){
        swap(X, Y);
    }
    i = 0;
    while(X>=0&&X<Y){
        X--;
        Y -= 2;
        i++;
    }
    if(X<0||X%3!=0){
        printf("0");
        return 0;
    }
    j = X / 3;
    printf("%lld", moddiv(Fa[i + j + j], Fa[i + j] * Fa[j]));
    return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 2005

int N,K;
int table[SIZE][SIZE],table2[SIZE][SIZE];

int calc(int x1,int y1,int x2,int y2){

	int base = table[x2][y2];
	if(y1 > 0){
		base -= table[x2][y1-1];
	}
	if(x1 > 0){

		base -= table[x1-1][y2];
	}
	if(x1 > 0 && y1 > 0){

		base += table[x1-1][y1-1];
	}

	return base;
}

int calc2(int x1,int y1,int x2,int y2){

	int base = table2[x2][y2];
	if(y1 > 0){
		base -= table2[x2][y1-1];
	}
	if(x1 > 0){

		base -= table2[x1-1][y2];
	}
	if(x1 > 0 && y1 > 0){

		base += table2[x1-1][y1-1];
	}

	return base;
}


int main(){

	scanf("%d %d",&N,&K);

	for(int x = 0; x < 2*K; x++){
		for(int y = 0; y < 2*K; y++){

			table[x][y] = 0;
			table2[x][y] = 0;
		}
	}

	int tmp_x,tmp_y;
	char buf[2];

	int num_black = 0,num_white = 0;

	for(int i = 0; i < N; i++){

		scanf("%d %d %s",&tmp_x,&tmp_y,buf);

		if(buf[0] == 'B'){
			num_black++;
			table[tmp_x%(2*K)][tmp_y%(2*K)]++;
		}else{
			num_white++;
			table2[tmp_x%(2*K)][tmp_y%(2*K)]++;
		}
	}

	int ans = 0;

	//まずは横に累積和
	for(int y = 0; y < 2*K; y++){
		for(int x = 1; x < 2*K; x++){
			table[x][y] += table[x-1][y];
			table2[x][y] += table2[x-1][y];
		}
	}

	//次に縦に累積和
	for(int x = 0; x < 2*K; x++){
		for(int y = 1; y < 2*K; y++){

			table[x][y] += table[x][y-1];
			table2[x][y] += table2[x][y-1];
		}
	}

	for(int sx = 0; sx <= K; sx++){
		for(int sy = 0; sy <= K; sy++){

			int sum = 0;
			int minus = 0;

			//左上
			if(sx > 0 && sy > 0){
				tmp_x = sx-1;
				tmp_y = sy-1;

				sum += calc(max(0,tmp_x-(K-1)),max(0,tmp_y-(K-1)),tmp_x,tmp_y);
				minus += calc2(max(0,tmp_x-(K-1)),max(0,tmp_y-(K-1)),tmp_x,tmp_y);
			}
			//右上
			if(sx+K-1 < 2*K-1 && sy > 0){

				tmp_x = sx+K;
				tmp_y = sy-1;

				sum += calc(tmp_x,max(0,tmp_y-(K-1)),min(2*K-1,tmp_x+K-1),tmp_y);
				minus += calc2(tmp_x,max(0,tmp_y-(K-1)),min(2*K-1,tmp_x+K-1),tmp_y);
			}

			//自分
			sum += calc(sx,sy,sx+K-1,sy+K-1);
			minus += calc2(sx,sy,sx+K-1,sy+K-1);

			//左下
			if(sx > 0 && sy+K-1 < 2*K-1){

				tmp_x = sx-1;
				tmp_y = sy+K;

				sum += calc(max(0,tmp_x-(K-1)),tmp_y,tmp_x,min(2*K-1,tmp_y+K-1));
				minus += calc2(max(0,tmp_x-(K-1)),tmp_y,tmp_x,min(2*K-1,tmp_y+K-1));
			}
			//右下
			if(sx+K-1 < 2*K-1 && sy+K-1 < 2*K-1){

				tmp_x = sx+K;
				tmp_y = sy+K;

				sum += calc(tmp_x,tmp_y,min(2*K-1,tmp_x+K-1),min(2*K-1,tmp_y+K-1));
				minus += calc2(tmp_x,tmp_y,min(2*K-1,tmp_x+K-1),min(2*K-1,tmp_y+K-1));
			}

			ans = max(ans,sum+num_white-minus); //選択領域を黒
			ans = max(ans,num_black-sum+minus); //選択領域を白
		}
	}

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

	return 0;
}


Measured memory_bytes: 31616
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static long MOD = 1_000_000_007;

	public static void main(String[] args) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		long[][] dp = new long[N + 1][K + 1];
		dp[0][K] = 1;
		for (int i = 0; i < N; i++) {
			long sum = 0;
			for (int j = 0; j < A[i] && j <= K; j++) {
				sum += dp[i][j];
			}
			sum %= MOD;
			for (int j = 0; j <= K; j++) {
				if (j + A[i] <= K) {
					sum += dp[i][j + A[i]];
					if (sum >= MOD) sum -= MOD;
				}
				dp[i + 1][j] = sum;
				sum += MOD - dp[i][j];
				if (sum >= MOD) sum -= MOD;
			}
		}
		System.out.println(dp[N][0]);
	}
}

Measured memory_bytes: 127056
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 1000003

int n, m, p, q, c, dist[mx], idx, kota[mx], company[mx];
set<int> daftar[mx];
vector<pair<int, int>> g[mx];

map<pair<int, int>, int> indeks;

int getindeks(int i, int j){
	if(indeks.count({i, j}))
		return indeks[{i, j}];
	kota[idx] = i;
	company[idx] = j;
	indeks[{i, j}] = idx++;
	return idx - 1;
}

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> p >> q >> c;
		p -= 1, q -= 1, c -= 1;
		g[p].pb({c, q});
		g[q].pb({c, p});
		daftar[p].insert(c);
		daftar[q].insert(c);
	}
	for(int i = 0; i < n; i++)
		sort(ALL(g[i]));
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
	reset(dist, -1);
	pq.push({0, getindeks(0, -1)});
	dist[getindeks(0, -1)] = 0;
	while(!pq.empty()){
		int now, dis;
		tie(dis, now) = pq.top();
		pq.pop();
		// debug(kota[now]);
		// debug(company[now]);
		// debug(dis);
		if(company[now] == -1){
			for(int i : daftar[kota[now]]){
				if(dist[getindeks(kota[now], i)] == -1 || dist[getindeks(kota[now], i)] > dis + 1){
					dist[getindeks(kota[now], i)] = dis + 1;
					pq.push({dis + 1, getindeks(kota[now], i)});
				}
			}
			continue;
		}
		// int it1, it2;
		int it1 = lower_bound(ALL(g[kota[now]]), make_pair(company[now], -1), [&](pair<int, int> x, pair<int, int> y){
			return x.f < y.f;
		}) - g[kota[now]].begin();
		int it2 = upper_bound(ALL(g[kota[now]]), make_pair(company[now], 1e9), [&](pair<int, int> x, pair<int, int> y){
			return x.f < y.f;
		}) - g[kota[now]].begin();
		for(int x = it1; x < it2; x++){
			auto i = g[kota[now]][x];
			assert(company[now] == i.f);
			int cost = 0;
			if(dist[getindeks(i.s, i.f)] == -1 || dist[getindeks(i.s, i.f)] > dis + cost){
				dist[getindeks(i.s, i.f)] = dis + cost;
				pq.push({dis + cost, getindeks(i.s, i.f)});
			}	
		}
		if(dist[getindeks(kota[now], -1)] == -1 || dist[getindeks(kota[now], -1)] > dis){
			dist[getindeks(kota[now], -1)] = dis;
			pq.push({dis, getindeks(kota[now], -1)});
		}
	}
	int jaw = dist[getindeks(n - 1, -1)];
	// for(int i : daftar[n - 1]){
	// 	if(dist[getindeks(n - 1, i)] == -1)
	// 		continue;
	// 	jaw = min(jaw, dist[getindeks(n - 1, i)]);
	// }
	if(jaw == 1e9)
		jaw = -1;
	cout << jaw << endl;
}

Measured memory_bytes: 141172
#include<stdio.h>

int main(void){

  int n;
  scanf("%d",&n);
  int a[n];
  int i,j,k;

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    a[i]=a[i]-1;
    //インデックスで
  }
  int hakai=0;
  int ima=0;
  for(i=0;i<n;i++){
    if(a[i]==ima){
      ima++;
    }
  }
  if(ima==0){
    printf("-1");
    return 0;
  }
  int ans=n-ima;
  printf("%d",ans);


  return 0;
}


Measured memory_bytes: 896
using System;
using System.Collections;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int k = int.Parse(input[2]);

        var alist = new List<int>();
        var ablist = new List<int>();
        for (int i = 1; i <= a; i++)
        {
            if (a % i == 0)
            {
                alist.Add(a / i);
            }
        }

        for (int i = 1; i <= b; i++)
        {
            if (b % i == 0 && alist.Contains(b / i))
            {
                ablist.Add(b / i);
            }
        }
        Console.WriteLine(ablist[k - 1]);

    }
}

Measured memory_bytes: 13152
import sys

def prob(cur, t):
    if cur >= t: return 1
    return 1.0/2.0 * prob(2*cur, t)

if __name__ == '__main__':
    input = sys.stdin.read()
    N, K = map(int, input.split())
    res = 0
    for i in xrange(1, N+1):
        res += 1.0/N * prob(i, K)
    print res

Measured memory_bytes: 2568
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------

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

  double sq = sqrt(n);
  ll a=1, b=1, ans=LONG_MAX;
  while(a<=sq){
    if(n%a==0){
      b=n/a;
      if(ans>a+b-2){
        ans = a+b-2;
      }
    }
    a++;
  }

  prt(ans);


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int T = 0;
    int S = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'S'){
            S++;
        } else {
            if(S > 0){
                S--;
            } else {
                ans++;
            }
        }
    }
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'T'){
            T++;
        } else {
            if(T > 0){
                T--;
            } else {
                ans++;
            }
        }
    }
    cout << ans << endl;


        return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    vector <int> v(m);
    generate(all(v),nxt);
    int sum=0;
    for(auto i:v)
        sum+=i;
    if(sum>n)
        cout<<"-1\n";
    else
        cout<<n-sum<<endl;
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 3684
#include<cstdio>
#include<string>
#define LEN 100005
using namespace std;

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) {
    return a < b ? a : b;
}

int main(void){
    // Your code here!
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for (i = 1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;
    
    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else {
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}



Measured memory_bytes: 12844
Module Module1

sub Main(ByVal args() as String)
    dim n as integer
    n = Console.ReadLine()

    dim arr(n) as string
    arr=Split(Console.ReadLine())
    dim a(n) as integer
    for i as integer = 0 to n - 1 step 1
        a(i) = arr(i)
    next i

    dim c as integer = 0
    do
        for i as integer = 0 to n - 1 step 1
            if a(i) mod 2 = 0 then
                a(i) = a(i) / 2
            else
                exit do
            end if
        next i

        c += 1
    loop

    Console.WriteLine(c)
end sub

end Module

Measured memory_bytes: 13536