akhauriyash/Code-Regression huggingface dataset:
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    sc.nextLine()
    val tList = sc.nextLine().replaceAll("\n", "").split(" ").toList.map(_.toInt)
    val m = sc.nextInt()
    sc.nextLine()
    var xtimes = List[List[Int]]()
    for (i <- 0 until m) {
      val t = sc.nextLine().replaceAll("\n", "").split(" ").toList.map(_.toInt)
      xtimes = xtimes :+ t
    }

    for (i <- xtimes) {
      val p = i.head
      val x = i(1)
      val sum = tList.sum
      val diff = x - tList(p - 1)
      println(sum + diff)
    }

  }

}


Measured memory_bytes: 22592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

pair<ll,ll> FizzBuzzSum(ll x) {

  ll t3 = (x) / 3;
  ll t5 = (x) / 5;
  ll t15 = (x) / 15;

  return {x - (t3 + t5 - t15), t3 + t5};
}

// l以上r未満 (桁数同じ)
ll calc(ll l, ll r) {
  int t = 0;
  ll tmp = l;

  while(tmp) {
    tmp /= 10;
    t++;
  }

  auto a = FizzBuzzSum(l-1);
  auto b = FizzBuzzSum(r-1);

  return t * (b.first - a.first) + 4 * (b.second - a.second);
}

// x未満
ll calc(ll x) {
  ll sum = 0;

  for(ll i=1; i<x; i*=10) {
    //cerr << i << " " << min(i*10, x) << " : " << calc(i, min(i*10, x)) << endl;
    sum += calc(i, min(i*10, x));
  }

  return sum;
}

char get(ll p) {
  ll l = 0, r = p;

  while(l < r) {
    ll mid = (r + l + 1) / 2;

    ll v = calc(mid);

    if (v < p)
      l = mid;
    else
      r = mid - 1;
  }

  ll s = calc(r);

  string str;


  if (r % 15 == 0) {
    str = "FizzBuzz";
  } else if (r % 3 == 0) {
    str = "Fizz";
  } else if (r % 5 == 0) {
    str = "Buzz";
  } else {
    str = to_string(r);
  }

  return str[p - s - 1];
}

int main(){
  ll s;

  cin >> s;

  string ans = "";

  for (int i=0; i<20; i++) {
    ans += get(s+i);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3268
n=int(input())
s=input()
ans=0
for i in range(10):
  idx1=s.find(str(i))
  for j in range(10):
    idx2=s.find(str(j),idx1+1,n)
    for k in range(10):
      idx3=s.find(str(k),idx2+1,n)
      if idx1==-1 or idx2==-1 or idx3==-1:
        continue
      else:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int A, B;
        cin >> A >> B;
        if (B +A >=24)
        {
                cout << B+A-24 << endl;
        }
        else
        {
                cout << B+A << endl;
        }

        return 0;
}


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


int N, Q;
string S;
int AC[100010] = {0};

int main() {
    cin >> N >> Q;
    cin >> S;
    int cnt = 0;
    for (int i = 0; i < N-1; i++) {
        if (S[i] == 'A' and S[i+1] == 'C') {
            cnt++;
        }
        AC[i+1] = cnt;
    }
    int l, r;
    for (int i = 0; i < Q; i++ ) {
        cin >> l >> r;
        int a = AC[r-1] - AC[l-1];
        cout << a << '\n';
    }

}



Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<vector>
#define N 2100
#define ll long long
#define RG register
#define MOD 998244353
using namespace std;

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

int n,k;
vector<int> V[N];

int main(){
	n=read();
	for(RG int i=1;i<=n+1;++i)
		if(i*(i-1)/2==n) { k=i; break ; }
	if(!k) return puts("No"),0;
	int tot=0;
	for(RG int i=1;i<=k;++i)
		for(RG int j=i+1;j<=k;++j)
			V[i].push_back(++tot),V[j].push_back(tot);
	puts("Yes"); cout<<k<<endl;
	for(RG int i=1;i<=k;++i){
		int Siz=V[i].size();
		printf("%d ",Siz);
		for(RG int j=0;j^Siz;++j) printf("%d ",V[i][j]);
		puts("");
	}   return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
const int INF = 1000000000;

struct Edge {
	int to, weight;
	Edge(int t = 0, int w = 0) : to(t), weight(w) { }
};

int solve(
	int u, int p, const vector<int> &c,
	const vector< vector<Edge> > &conn)
{
	if(c[u] > 0){ return INF; }
	int sum = 0;
	for(int i = 0; i < conn[u].size(); ++i){
		const int v = conn[u][i].to;
		if(v == p){ continue; }
		sum += min(conn[u][i].weight, solve(v, u, c, conn));
	}
	return sum;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> c(n);
	for(int i = 1; i < n; ++i){ cin >> c[i]; }
	vector< vector<Edge> > conn(n);
	for(int i = 1; i < n; ++i){
		int a, b, c;
		cin >> a >> b >> c;
		conn[a].push_back(Edge(b, c));
		conn[b].push_back(Edge(a, c));
	}
	cout << solve(0, -1, c, conn) << endl;
	return 0;
}

Measured memory_bytes: 1268
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan =new Scanner(System.in);
		int A=scan.nextInt();
		int B =scan.nextInt();
		int C=scan.nextInt();
		int a=0;
		if(A==B&&B!=C) {
			a=1;
		}
		if(B==C&&C!=A) {
			a=1;
		}
		if(A==C&&C!=B) {
			a=1;
		}
		
		if(a==1) {
			System.out.println("Yes");
		}
		else if(a==0) {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
	int N,A;
	cin>>N>>A;
	string ans="No";
	if (N%500<=A)ans="Yes";
	cout<<ans<<endl;
}

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

int N;
int main(){
	cin>>N;
	int hasil;
	for(int i=1;i<=9; i++){
		if(N%i==0){
			hasil=N/i;
			if(hasil<=9){
				cout<<"Yes"<<'\n';
				return 0;
			}
		}
		if(i==9){
			cout<<"No"<<'\n';
		}
	}
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005,MAX = 1e9;
int n,k,dp[N],way[N];
int main(){
    scanf("%d %d",&n,&k);
    for(int i = 1;i <= n;i++) scanf("%d",&way[i]);
    for(int i = 2;i <= n;i++){
        dp[i] = MAX;
        for(int j = 1;j <= k && i-j >= 1;j++)
            dp[i] = min(dp[i],dp[i-j]+abs(way[i]-way[i-j]));
        //printf("%d ",dp[i]);
    }
    printf("%d",dp[n]);
    return 0;
}

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

int main() {
  int N , K, totalMoveValue = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    int robotA, robotB;
    robotA = x * 2;
    robotB = (K - x) *2;
    totalMoveValue += min(robotA, robotB);
  }
  
  cout << totalMoveValue << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		//System.out.println("Working!");
		int a,b,c,t;
		try (Scanner sc = new Scanner(System.in)) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
		}
		//System.out.println("Come here!");

		if(a>b) {
			t = a;
			a = b;
			b = t;
		}

		if(b>c) {
			t = b;
			b = c;
			c = t;
		}

		if(a>b) {
			t = a;
			a = b;
			b = t;
		}

		System.out.println(String.format("%d %d %d", a, b, c));
	}

}



Measured memory_bytes: 26252
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

vector <bool> eratosthenes(int n) {
	vector <bool> prime(n + 1, true);
	prime = vector <bool> (n + 1, true);
	if(n >= 0) prime[0] = false;
	if(n >= 1) prime[1] = false;
	for(int i = 2; i * i <= n; i++)
		if(prime[i])
			for(int j = i * 2; j < n; j += i)
				prime[j] = false;
	return prime;
}


signed main() {
	vector <bool> sosu = eratosthenes(50100);
	int n;
	while (cin >> n) {
		int mini = 0;
		rep (i, n) if (sosu[i]) mini = i;
		cout << mini << " ";
		for (int i = n + 1; ; i++) if (sosu[i]) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N = 19, inf = 1e8;

int n, a[N], b[N], dp[1 << N][51];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	memset(dp, 62, sizeof(dp));
	dp[0][1] = 0;
	for(int mask = 0; mask < (1 << n) - 1; mask++){
		int p = __builtin_popcount(mask) + 1;
		for(int val = 1; val <= 50; val++){
			if(dp[mask][val] >= inf) continue;
			int cost = 0;
			for(int i = 1; i <= n; i++){
				if(mask & (1 << (i - 1))) continue;
				int newmask = mask ^ (1 << (i - 1));
                int diff = abs(p - i) % 2, cur = a[i];
                if(diff == 1) cur = b[i];
                if(cur < val){
					cost++;
					continue;
                }
                dp[newmask][cur] = min(dp[newmask][cur], dp[mask][val] + cost);
				cost++;
			}
		}
	}
	int ans = inf;
	for(int i = 1; i <= 50; i++){
		ans = min(ans, dp[(1 << n) - 1][i]);
	}
	if(ans >= inf) cout << -1;
	else cout << ans;
}


Measured memory_bytes: 104704
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			int casenum=0;
			while(sc.hasNext()) {
				int W=sc.nextInt();
				if(W==0) break;
				int N=sc.nextInt();
				casenum++;
				int[] dp=new int[1010];
				int v, w;
				int sum=0, max=0;
				for(int i=0; i<N; i++) {
					String str=sc.next();
					String[] token=str.split(",");
					v=Integer.parseInt(token[0]);
					w=Integer.parseInt(token[1]);
					sum+=w;
					for(int j=Math.min(W, sum); j>=w; j--) {
						dp[j]=Math.max(dp[j], dp[j-w]+v);
						max=Math.max(dp[j], max);
					}
				}
				
				System.out.println("Case "+casenum+":");
				System.out.println(max);
				for(int i=0; i<=W; i++) {
					if(dp[i]==max) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
} 


Measured memory_bytes: 30864
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
int n,l,r;
main(){
  cin>>n>>l>>r;
  if(r<l)cout<<0<<endl;
  else if(n==1){
    if(l==r)cout<<1<<endl;
    else cout<<0<<endl;
  }
  else cout<<(n-1)*r+l-(n-1)*l-r+1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

int solve (int  i, int m){
  if ( m == 0 )
    return 1;
  if ( i >= n )
    return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){
  int q, M, i;
  scanf("%d",&n);
  for ( i = 0; i < n; i++ )
  scanf("%d", &A[i]);
 scanf("%d",&q);
  for ( i = 0; i < q; i++ ){
  scanf("%d", &M);
  if ( solve(0, M) )
    printf("yes\n");
  else
    printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

#define int long


 signed main(){
  string s;
  cin >> s;
  int n = s.size()+1;
//  int *a;
//  a = (int *)malloc(n*sizeof(int));
  int a[n];
  //vector<int> a(n,0);

  int cnt=0;
  for(int i=0; i<n;i++){
    if(s[i] == '<'){
      a[i] = cnt;
      cnt++;
    }else{
      a[i]=cnt;
      cnt=0;
    }
  }
  cnt=0;
  for(int i=n-1;i>=0;i--){
    if(s[i] == '>'){
      cnt++;
      a[i] = max(a[i],cnt);
    }else{
      cnt =0;
      a[i] = max(a[i],cnt);
    }
  }
  int ans=0;
  for(int i=0; i< n; i++){
    ans += a[i];
  }
  //cout << "\n" << ans << endl;
  cout << ans;
  return 0;
}


Measured memory_bytes: 4740
n = int(input())
def sumNum(i):
    if i//10 == 0:
        s = i
    else:
        s = 0
    while i//10 > 0:
        s += i%10
        if i//10 < 10:
            s += i//10
        i = i//10
    return s

sumab = float('inf')
for i in range(1,n):
    j = n - i
    tmp = sumNum(i) + sumNum(j)
    if tmp < sumab:
        sumab = tmp
print(sumab)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  int N,M; cin >> N >> M;

  vector<pair<ll,int>> v[N+1];//intは何番目のデータであるか,llは何年に成立したか.v[num]のnumは何県に属するか.

  for(int i = 1;i <= M;i++){

    int P; cin >> P;
    ll Y; cin >> Y;
    v[P].push_back(make_pair(Y,i));

  }

  for(int i = 1;i <= N;i++)sort(v[i].begin(),v[i].end());

  map<int,pair<int,int>> mp;//map<num,pair<prefec,year_order>>

  for(int i = 1;i <= N;i++){
    for(int j = 0;j < v[i].size();j++){
      mp[v[i][j].second] = make_pair(i,j+1);
    }
  }

  for(int i = 1;i <= M;i++){
    int first = mp[i].first;
    int second = mp[i].second;
    printf("%06d%06d\n",first,second);
  }

}


Measured memory_bytes: 13184
#include <iostream>
using namespace std;
int main() {
    string small = "abcdefghijklmnopqrstuvwxyz";
    string big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string inp;
    getline(cin, inp);
    
    for(int i = 0; i < inp.size(); i++){
        for(int j = 0; j < 26; j++){
            if(inp.at(i) == small.at(j)){
                inp.at(i) = big.at(j);
            }
            else if(inp.at(i) == big.at(j)){
                inp.at(i) = small.at(j);
            }
            else{
                continue;
            }
        }
    }
    cout << inp << endl;
    
    return 0;
}



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

int n,W;
int v[101],w[101];
int dp[101][10001];

int main(){
 cin>>n>>W;
 for(int i=0;i<n;i++){
  cin>>v[i]>>w[i];
 }
 for(int i=0;i<n;i++){
  for(int j=0;j<=W;j++){
   if(j+w[i]<=W)dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
   dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
  }
 }
 int ans=0;
 for(int i=W;i>=0;i--){
  ans=max(dp[n][i],ans);
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 7004
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut 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 ,) =>{} ;($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 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        a: u64,
        b: u64,
    }
    for i in 1..100000 {
        let x: f64 = i as f64;
        if (x * 0.08) as u64 == a && (x * 0.1) as u64 == b {
            println!("{}", i);
            return;
        }
    }
    println!("{}", -1);
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
     string s;
    cin>>s;
   int count = 0,a=s.size()-1;
   for(int i=0;i<s.size()/2;i++){
       if(s[i]!=s[a-i]){
           count++;
       }
   }
   cout<<count<<endl;
}

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

struct edge{int from,to,cost;};

int n,m,s;
vector<edge>v;
int d[10009];

void Bellman(){
  fill(d,d+10009,1e16);
  d[s]=0;
  for(int i=0;i<n;i++){
    //int update=0;
    for(int j=0;j<m;j++){
      edge e=v[j];
      if(d[e.from]!=1e16&&d[e.to]>d[e.from]+e.cost){
        d[e.to]=d[e.from]+e.cost;
        //update=1;
        if(i==n-1&&e.to==n-1){
          cout<<"inf"<<endl;
          return;
        }
      }
    }
    //if(!update)break;
  }
  cout<<d[n-1]*(-1)<<endl;
}
main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--,c*=(-1);
    v.push_back({a,b,c});
  }
  Bellman();
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    int i,j,k,l,r,x,y; string S,T;
    bool exit = false;
    cin>>S>>T;
    string latter;
    string first;
    string U;
    FOR(i,S.size()){
        first = "";
        latter = "";
        FOR(j,i)
            first += S[j];
        for(j=i;j<S.size();j++)
            latter += S[j];
        U = latter;
        U += first;
        //cout<< U<<endl;
        //judge
        if(U==T){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
    return;
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

template <typename T>
struct Graph {
  int n;
  vector<vector<pair<int, T>>> to;
  Graph(int n) : n(n), to(n) {}
  void add_edge(int s, int t, T cost=1) {
    to[s].push_back(pair<int, T>(t, cost));
  }
  vector<T> dijkstra(int s, T init) {
    vector<T> d(n, init);
    d[s] = 0;
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>> > pq;
    pq.push(pair<T, int>(0, s));
    while (!pq.empty()) {
      int v = pq.top().second; pq.pop();
      for (auto u : to[v]) {
        if (d[v] + u.second < d[u.first]) {
          d[u.first] = d[v] + u.second;
          pq.push(pair<T, int>(d[u.first], u.first));
        }
      }
    }
    rep2(i,1,n){
      for(auto u:to[i]){
        if(d[u.fi]+1==d[i]){
          cout<<u.fi+1<<endl;
          break;
        }
      }
    }
    return d;
  }
};

int main(){
  int n,m;
  cin>>n>>m;
  Graph<ll>g(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g.add_edge(a,b);
    g.add_edge(b,a);
  }
  cout<<"Yes"<<endl;
  g.dijkstra(0,INF);
  return(0);
}


Measured memory_bytes: 18756
import statistics
import math

N = int(input())

A = list(map(int, input().split()))
A = [A[i] - i for i in range(N)]
med = round(statistics.median(A))

s0 = sum([abs(A[i] - med) for i in range(N)])
s1 = sum([abs(A[i] - med -1) for i in range(N)])
s2 = sum([abs(A[i] - med + 1) for i in range(N)])

print(min(s0, s1, s2))

Measured memory_bytes: 27252
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-6
//#define p 2173412051LL
//#define sz 2

using namespace std;

pair< int, int > a[ 200010 ];
ll f[ 200010 ][ 2 ];
stack< int > s;

int main() {
	int n, t;
	ll p = 998244353;
	scanf( "%d", &n );
	for( int i = 0; i < n; ++i )
		scanf( "%d%d", &a[ i ].first, &a[ i ].second );
	sort( a, a + n );
	a[ n ] = { 2e9, 0 };
	f[ n ][ 0 ] = 1;
	s.push( n );
	for( int i = n - 1; i >= 0; --i ) {
		while( !s.empty() && a[ s.top() ].first < a[ i ].first + a[ i ].second )
			s.pop();
		t = s.top();
		f[ i ][ 0 ] = ( f[ i + 1 ][ 0 ] + f[ i + 1 ][ 1 ] ) % p;
		f[ i ][ 1 ] = ( f[ t ][ 0 ] + f[ t ][ 1 ] ) % p;
		s.push( i );
	}
	printf( "%lld", ( f[ 0 ][ 0 ] + f[ 0 ][ 1 ] ) % p );
	return 0;
}

Measured memory_bytes: 5376
import sys
import numpy as np
import numba
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            # k 日目に入るスコアの変更
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

def output(T):
    T += 1
    print(*T, sep='\n')

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :]), cache=True)
def random_update(D, C, S, T, last_days):
    d = np.random.randint(0, D, 1)[0]
    p = T[d]
    xcum = 0
    for q in range(26):
        if p == q:
            continue
        xcum += difference_update(D, C, S, T, last_days, d, q)
        if xcum > 0:
            return q, xcum
    difference_update(D, C, S, T, last_days, d, p)
    return p, 0

@njit((i4, i4[:], i4[:, :], i4[:], i4[:,:]), cache=True)
def main(D, C, S, T, last_days):
    x = 0
    for _ in range(10**5):
        x += random_update(D, C, S, T, last_days)[1]
    return T, x

def first_strategy(D, C, S):
    T = np.empty(D, np.int32)
    for d in range(D):
        T[d] = d % 26
    return T

D, C, S = get_input()

T = first_strategy(D, C, S)
last_days, score = first_computation(D, C, S, T)

T, x = main(D, C, S, T, last_days)

output(T)

Measured memory_bytes: 107940
//////AGC039-B//////
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
int n,m,l,q,ans=0;
void Main(){
    cin>>n;
    vector<int> d(n);
    For(i,0,n) cin>>d.at(i);
    For(i,0,n){
        For(j,i+1,n){
            ans+=d.at(i)*d.at(j);
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


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

int n, l;

int main() {
    cin >> n >> l;
    vector<int> taste(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        taste[i] = l+i;
        sum += taste[i];
    }
    vector<int> abstaste(n);
    for (int i = 0; i < n; i++) abstaste[i] = abs(taste[i]);
    auto iter = min_element(abstaste.begin(), abstaste.end());
    int ans = sum - taste[iter-abstaste.begin()];
    cout << ans << endl;
    return 0;
}

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

const int MOD = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    if(abs(n - m) >= 2) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    if(abs(n - m) == 1) {
        repl(i, 1, n + 1) {
            ans *= i;
            ans %= MOD;
        }
        repl(i, 1, m + 1) {
            ans *= i;
            ans %= MOD;
        }
    }
    else {
        repl(i, 1, n + 1) {
            ans *= i;
            ans %= MOD;
        }
        repl(i, 1, m + 1) {
            ans *= i;
            ans %= MOD;
        }
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3560
def solve():
    N, *d_l = map(int, open(0).read().split())
    d_l.sort()

    if d_l[N//2] == d_l[N//2-1]:
        print(0)
    else:
        print(d_l[N//2] - d_l[N//2-1])



if __name__ == '__main__':
    solve()

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

int main() {
  int N, M; cin >> N >> M;
  vector<int> L(M), R(M);
  rep(i, M) cin >> L[i] >> R[i];
  
  int ans = N;
  int l=1, r=N;
  
  rep(i, M) {
    if(L[i] > l) l = L[i];
    if(R[i] < r) r = R[i];
  }
  
  if(r-l < 0) {
    cout << 0 <<endl;
    return 0;
  }
  cout << r-l+1 << endl;
  
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(W,n)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {REP(aaa,i){REP(bbb,j)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

vector<vector<int>> v(111111);
ll mpL[111111];
ll mpR[111111];
bool visited[111111];

void dfs(int node, int pre,ll LL, ll RR){
	//cout << node << " " << LL << " " << RR << endl;
	if(visited[node] && node != pre && mpL[node] >= LL && mpR[node] <= RR)return;
	visited[node] = true;
	mpL[node] = max(mpL[node], LL);
	mpR[node] = min(mpR[node], RR);
	if(mpL[node] > mpR[node])return;

	REP(i,v[node].size()){
		if(v[node][i] == pre)continue;
		dfs(v[node][i], node, mpL[node] - 1, mpR[node] + 1);
	}
}

int main(){

	int n;cin >> n;
	REP(i,n-1){
		int a,b;cin >> a >> b;
		a--;b--;
		v[a].PB(b);
		v[b].PB(a);
	}
	REP(i,111111){
		mpL[i] = -LLINF;
		mpR[i] = LLINF;
	}
	int k;cin >> k;
	vector<P> que;
	REP(i,k){
		ll a,b;cin >> a >> b;a--;
		que.EB(a,b);
		mpL[a] = b;
		mpR[a] = b;
	}

	REP(i,k)dfs(que[i].FI, que[i].FI, que[i].SE, que[i].SE);

	bool flag = true;
	REP(i,n){
		if(mpL[i] > mpR[i])flag = false;
		REP(j,v[i].size())if(abs(mpR[i]-mpR[v[i][j]]) != 1)flag = false;
	}
	if(!flag){
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		REP(i,n)cout << mpR[i] << endl;
	}

	return 0;
}


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

typedef long long ll;
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
const double pi = acos(-1.0);

// HxW
// r,c

// white path

char s[110][110];

int ans[110][110];

// bfs ?
// 1 2 3 4 5 6 7
// w b w b w b w  7/2= 3
// w b w b w b  6/2=3
// b w b w b    5/2=2
// b w b w b w  6/2=3
int h,w;

pair<int,int> arr[2][10010];
int st[2];
int rear[2];

int main(){
  cin>>h>>w;
  rep(i,0,h){
    scanf("%s",s[i]);
  }
  ans[0][0]=1;
  rep(i,1,h){
    ans[i][0] = ans[i-1][0] + (s[i][0] !=s[i-1][0]);
  }
  rep(j,1,w){
    ans[0][j] = ans[0][j-1] + (s[0][j] !=s[0][j-1]);
  }
  rep(i,1,h){
    rep(j,1,w){
      ans[i][j] = min(ans[i-1][j]+(s[i][j]!=s[i-1][j]),ans[i][j-1]+(s[i][j]!=s[i][j-1]));
    }
  }
  if(s[0][0] == '#' && s[h-1][w-1] =='#'){
    printf("%d\n",ans[h-1][w-1]/2+1);
  }else{
    printf("%d\n",ans[h-1][w-1]/2);
  }

  return 0;
}


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

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool d = 1;
  rep(i, s.size()){
    if(i == a){
      if(s[i] != '-'){
        d = 0;
        break;
      }
    }
    else if(s[i] >= '0' && s[i] <= '9') continue;
    else{
      d = 0;
      break;
    }
  }
  if(d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  string s; cin >> s;
  vector<int> v(4); rep(i,4) v[i] = (int)s[i]-48;
  rep(bit,1<<3){
    vector<int> tmp(4); tmp=v;
    rep(i,3) if(bit & 1<<i) tmp[i+1] *= -1;
    if(accumulate(all(tmp), 0) == 7){
      cout << tmp[0];
      rep(i,3){
        if(!(bit & 1<<i)) cout << "+" << tmp[i+1];
        else cout << tmp[i+1];
      }
      cout << "=7";
      return 0;
    }
  }
  
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long N;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
long power(long a,long b,long mod){return b?power(a*a%mod,b/2,mod)*(b%2?a:1)%mod:1;}
int phi(int N)
{
	int ret=N;
	for(int i=2;i*i<=N;i++)
	{
		if(N%i==0)
		{
			while(N%i==0)N/=i;
			ret=ret/i*(i-1);
		}
	}
	if(N>1)ret=ret/N*(N-1);
	return ret;
}
main()
{
	cin>>N;
	if(N==2)
	{
		cout<<1<<endl;
		return 0;
	}
	int tN=N;
	int L=1;
	for(int i=2;i*i<=tN;i++)
	{
		if(tN%i==0)
		{
			tN/=i;
			if(tN%i==0)
			{
				cout<<-1<<endl;
				return 0;
			}
			L=L/gcd(L,i-1)*(i-1);
		}
	}
	if(tN>1)
	{
		L=L/gcd(L,tN-1)*(tN-1);
	}
	int nl=phi(L);
	int ans=nl+1;
	for(int i=1;i*i<=nl;i++)
	{
		if(nl%i==0)
		{
			if(power(N,i,L)==1)ans=min(ans,i);
			if(power(N,nl/i,L)==1)ans=min(ans,nl/i);
		}
	}
	cout<<(ans>nl?-1:ans)<<endl;
}


Measured memory_bytes: 3108
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int M = 1 << 16 | 5, N = 18, mod = 1e9 + 7;

int f[N][M], inv[M], fac[M], ifac[M], a[N], pw[N], cnt[M];

inline int binom(int n, int m) { 
	if (n < m || n < 0 || m < 0) return 0;
	if (n == m || m == 0) return 1;
	return 1ll * fac[n] * ifac[n - m] % mod * ifac[m] % mod;
}

inline int add(int x, int y) {return x += y, x >= mod ? x - mod : x;}
inline int sub(int x, int y) {return x -= y, x < 0 ? x + mod : x;}

int main() {
	inv[0] = inv[1] = fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
	pw[0] = 1; for (int i = 1; i <= 16; ++i) pw[i] = pw[i - 1] * 2; 
	cnt[0] = 1; cnt[1] = mod - 1;
	for (int i = 2; i < M; ++i) {
		inv[i] = 1ll * inv[mod % i] * (mod - mod / i) % mod;
		fac[i] = 1ll * fac[i - 1] * i % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
		cnt[i] = (i & 1) ? mod - cnt[i >> 1] : cnt[i >> 1];
	}
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + m + 1); 
	f[m][0] = 1; 
	for (int i = m; i; --i) 
		for (int S = 0; S < (1 << n); ++S) if (f[i][S]) {
			f[i - 1][S] = add(f[i - 1][S], f[i][S]);
			int p = (1 << n) - 1 - S;
			if (p > 0) for (int j = 0; j < n; ++j) if ((~S) >> j & 1) 
				f[i - 1][S | (1 << j)] = add(f[i - 1][S | (1 << j)], 1ll * f[i][S] * binom(p - a[i] + 1, (1 << j) - 1) % mod * fac[1 << j] % mod);
 		}
	int ans = 0;
	for (int i = 0; i < (1 << n); ++i)
		ans = add(ans, 1ll * f[0][i] * fac[((1 << n) - 1 - i)] % mod * cnt[i] % mod);
	ans = 1ll * ans * (1 << n) % mod;
	printf("%d\n", ans);
	return 0;
}

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

// 各桁の和を計算する関数
int sumOfDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int sum = sumOfDigits(N);
  if (N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n, m, x, y = list(map(int, input().split()))
xl = [int(i) for i in input().split()]
yl = [int(i) for i in input().split()]
xl.append(x)
yl.append(y)

if max(xl) < min(yl):
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int M = cin.Int();
        var X = cin.ArrayInt(M);

        if (N >= M) Console.WriteLine(0);
        else {
            Array.Sort(X);
            var L = new int[M - 1];
            for (int i = 0; i < M - 1; i++) {
                L[i] = X[i + 1] - X[i];
            }
            L = L.OrderByDescending(x => x).ToArray();
            int tmp = 0;
            for (int i = 0; i < N - 1; i++) {
                tmp += L[i];
            }
            Console.WriteLine(X[M - 1] - X[0] - tmp);
        }

        Console.ReadLine();
    }
}

Measured memory_bytes: 24172
l, r = map(int, input().split())

a = l % 2019
b = r % 2019

if b - a == r - l:
    min_prod = 2018*2017
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            if i*j%2019 < min_prod:
                min_prod = i*j%2019
    print(min_prod)
else:
    print(0)






Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}

struct P {
  string name;
  int score;
  int num;
};

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

  int N;
  cin >> N;
  vector<P> X(N);
  rep(i, N) {
    cin >> X[i].name >> X[i].score;
    X[i].num = i+1;
  }
  std::sort(X.begin(), X.end(), [](P& l, P& r){return ((l.name == r.name)?(l.score > r.score):(l.name < r.name));});
  rep(i, N) {
    cout << X[i].num << '\n';
  }
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>
#include <queue>

using namespace std;

#define MOD 1000000007

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = float('inf')
for i in range(1,N):
    A = i
    B = N - i
    Sum = 0
    for power in range(4,-1,-1):
        q_a,r_a = divmod(A,10**power)
        A = r_a
        q_b,r_b = divmod(B,10**power)
        B = r_b
        Sum += q_a + q_b
    ans = min(Sum, ans)
print(ans)


Measured memory_bytes: 73576
import Data.List
import Data.Char

main=do
    s<-getLine
    putStrLn $ f1 s
    --
    return ()

f1 (a:sr)
    | a /= 'A' = "WA"
    | otherwise = f2 sr

f2 (a:sr) = f3 (a:v) u
    where (u,v) = splitAt ((length sr)-1) sr

f3 ss sc =
    case findIndices (=='C') sc of
        [i] -> f4 (ss ++ filter (/='C') sc)
        otherwise -> "WA"

f4 xx = if all isLower xx then "AC" else "WA"

Measured memory_bytes: 380
from collections import Counter
N = int(input())
A = sorted(Counter(list(map(int, input().split()))).items(), key=lambda x: x[0])
if len(A) != (N + 1) // 2:
    print(0)
    exit()
if N % 2 == 1:
    if A[0][0] != 0 or A[0][1] != 1:
        print(0)
        exit()
    for (a, n), i in zip(A[1:], range(2, N + 1, 2)):
        if a != i or n != 2:
            print(0)
            exit()
else:
    for (a, n), i in zip(A, range(1, N + 1, 2)):
        if a != i or n != 2:
            print(0)
            exit()
print(2 ** (N // 2) % (10 ** 9 + 7))


Measured memory_bytes: 15312
/* include */
#include <iostream>
#include <vector>

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long

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

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int n,m,x;
    int ans1=0,ans2=0;
    vector<int> v(n,0); 
    cin>>n>>m>>x;
    rep(i,m){
        int tmp;
        cin>>tmp;
        v[tmp]=1;
    }
    for(int i=n-1;i>=x;i--){
        if(v[i]==1){
            ans1++;
        }
    }
    for(int i=0;i<x;i++){
        if(v[i]==1){
            ans2++;
        }
    }
    cout<<min(ans1,ans2)<<endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, a[100001];
  cin >> n;
  int c = 0;
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) {
    if(a[i] % 2 == 0) {
      while(a[i] % 2 == 0) {
        c++;
        a[i] /= 2;
      }
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>> a >> b;
    if(a<b){
    cout<< "a < b" <<endl;
}if(a>b){
    cout<< "a > b" <<endl;
}if(a==b){
    cout<< "a == b" <<endl;
}
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
 
#define ulli unsigned long long int
 
int main(){
   
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    
    int n,k;
    
    cin>>n>>k;
    
    vector <lli> h(n+1),dp(n+1,1000000000);
    
    for(int i=1; i<=n; i++){
    	
    	cin>>h[i];
	}
	
	dp[1] = 0;
	
	for(int i=1; i<=n; i++){
		
		for(int j=0; j<=k; j++){
			
			if(i+j <= n){
				
				dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
			}
		}
	}
	
	cout<<dp[n];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    //set <int>r[3],c[3],d[2];
    int i,j,n,a[10],k,b,bin[3][3];
    for(i=0;i<3;++i)
        {
            for(j=0;j<3;j++)
            {
                cin>>bin[i][j];
                
            }
        }
    cin>>n;
    for(i=0;i<n;++i)
    cin>>a[i];
    while(n--)
    {
        b=a[n];
        for(i=0;i<3;++i)
        {
            for(j=0;j<3;j++)
            {
                if(b==bin[i][j])
                {
                    bin[i][j]=-1;
                }
                
            }
        }
    }
    for(j=0;j<3;++j){
    for(i=0;i<3;++i)
    {
        if(bin[i][j]!=-1)
            break;
    }
    if(i==3)
    {
        cout<<"Yes\n";
        return;
    }

    }
    for(j=0;j<3;++j){
    for(i=0;i<3;++i)
    {
        if(bin[j][i]!=-1)
            break;
    }
    if(i==3)
    {
        cout<<"Yes\n";
        return;
    }

    }
    {
    for(i=0;i<3;++i)
    {
        if(bin[i][i]!=-1)
            break;
    }
    if(i==3)
    {
        cout<<"Yes\n";
        return;
    }

    }
    for(i=0;i<3;++i)
    {
        if(bin[i][2-i]!=-1)
            break;
    }
    if(i==3)
    {
        cout<<"Yes\n";
        return;
    }
    cout<<"No\n";
    return;
}
signed main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    // int _t;cin>>_t;while(_t--)
    solve();
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
P = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda n:int(n) - 1, input().split())
    P[a].append(b) 
    P[b].append(a)

q = deque([0])
counts = [-1] * N
counts[0] = 0
while q:
    state = q.popleft()
    c = counts[state]
    for np in P[state]:
        if counts[np] < 0:
            counts[np] = state
            q.append(np)

if -1 in counts:
    print('No')
else:
    print('Yes')
    for c in counts[1:]:
        print(c+1)


Measured memory_bytes: 34808
// #1140935 Solution for 0515: School Road by ryogo 
#include<iostream>
using namespace std;
int dp[20][20];
int main(){
	int a,b;
	while(cin>>a>>b){
		if(a == 0 && b == 0) { break; }
		int n;
		cin>>n;
		for(int i=1;i<=16;i++)for(int j=1;j<=16;j++)dp[i][j]=0;
		for(int i=1;i<=n ;i++){
			int x,y;
			cin>>x>>y;
			dp[y][x]=-1;
		}
		dp[1][1]=1;
		for(int i=1;i<=b;i++){
			for(int j=1;j<=a;j++){
				if(i==1 && j==1)continue;
				if(dp[i][j]!=-1){
					dp[i][j]=dp[i][j-1]+dp[i-1][j];
				}
				else dp[i][j]=0;
			}
		}
 
		cout<<dp[b][a]<<endl;
	}
}


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

int main(){
    int N, Y;
    cin >> N >> Y;
    
    int flag=0;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=N; j++){
            if(10000*i+5000*j+1000*(N-(i+j))==Y && (N-(i+j)>=0)){
                flag=1;
                cout << i <<" "<< j <<" "<< N-(i+j) << endl;
                break;
            }
        }
        if(flag) break;
    }
    if(flag==0) cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rint register int
using namespace std;
int a,b; 
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  scanf("%d%d",&a,&b);
  if(a<b||a<2*b)
  {
  	puts("0");
  	return 0;
  }
  printf("%d\n",a-2*b);
  return 0;
}


Measured memory_bytes: 256