akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

const int MAX_V = 50;
const int MAX_S = MAX_V * 50 + 5;
const ll INF = 1e18;

struct Edge {
  int to, a, b;
  Edge(int to, int a, int b) : to(to), a(a), b(b) {}
};

struct Data {
  int v, s;
  ll x;
  Data(int v, int s, ll x) : v(v), s(s), x(x) {}
  bool operator<(const Data& d) const { return x > d.x; }
};

vector<Edge> g[MAX_V];
ll dp[MAX_V][MAX_S + 5];

int main() {
  int N, M, S0;
  cin >> N >> M >> S0;
  ll u, v, a, b;
  for (int i = 0; i < M; i++) {
    cin >> u >> v >> a >> b;
    u--;
    v--;
    g[u].emplace_back(v, a, b);
    g[v].emplace_back(u, a, b);
  }
  vector<int> C(N), D(N);
  for (int i = 0; i < N; i++) {
    cin >> C[i] >> D[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < MAX_S + 5; j++) {
      dp[i][j] = INF;
    }
  }
  S0 = min(S0, MAX_S);

  priority_queue<Data> q;
  auto push = [&](int v, int s, ll x) {
    if (s < 0) return;
    if (dp[v][s] <= x) return;
    dp[v][s] = x;
    q.emplace(v, s, x);
  };
  push(0, S0, 0);
  while (!q.empty()) {
    Data cur = q.top();
    q.pop();
    int v = cur.v, s = cur.s;
    ll x = cur.x;
    if (dp[v][s] != x) continue;
    {
      int next_s = min(s + C[v], MAX_S);
      push(v, next_s, x + D[v]);
    }
    for (Edge e : g[v]) {
      push(e.to, s - e.a, x + e.b);
    }
  }
  for (int i = 1; i < N; i++) {
    ll ans = INF;
    for (int j = 0; j < MAX_S + 5; j++) {
      ans = min(ans, dp[i][j]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 6128
#include<stdio.h>
#define INF 999

int main()
{
	int N,V,graph[20][20],node[20],node2[20],s,t,x,y,i,j,f,g;

	scanf("%d%d",&V,&N);
	for(i=0;i<V;i++)
	{
		for(j=0;j<V;j++)
			graph[i][j]=INF;
		node[i]=node2[i]=INF;
	}
	for(i=0;i<=N;i++)
	{
		scanf("%d,%d,%d,%d",&s,&t,&x,&y);
		s--,t--;
		if(i!=N)
		{
			graph[s][t]=x;
			graph[t][s]=y;
		}
	}
	node[s]=node2[t]=0;
	while(1)
	{
		f=g=0;
		for(i=0;i<V;i++)
			for(j=0;j<V;j++)
			{
				if(node[i]!=INF&&graph[i][j]!=INF&&node[j]>node[i]+graph[i][j])
				{
					f=1;
					node[j]=node[i]+graph[i][j];
				}
				if(node2[i]!=INF&&graph[i][j]!=INF&&node2[j]>node2[i]+graph[i][j])
				{
					g=1;
					node2[j]=node2[i]+graph[i][j];
				}
			}
		if(!f&&!g)
			break;
	}
	printf("%d\n",x-y-node[t]-node2[s]);
	return 0;
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  vector<int> l(n), r(n);
  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);
  for(int i = n-1; i >= 1; i--) r[i-1] = gcd(r[i], a[i]);
  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i], r[i]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll h,ll a)
{
    ll moves ;
    if((h % a) == 0) moves = h/a;
    else moves = (h/a)+1;
    cout<<moves<<"\n";
}
int main()
{
    KAKA
    ll h,a;
    cin>>h>>a;
    Compute(h,a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    string s; cin>>s;
    bool isok = true;
    rep(i, 3){
        if(s[i] == s[i+1]) isok = false;
    }
    cout << (isok?"Good":"Bad")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<string> YN={"NO","YES"};
    vector<string> yn={"No","Yes"};
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(a+b==c+d?"Balanced":(a+b>c+d?"Left":"Right"))<<endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, a: [usize; n]);
    if a.iter().any(|x| *x == 0) {
        println!("{}", 0);
        return;
    }
    let mut ret = 1usize;
    for ai in a {
        let x = ret.overflowing_mul(ai);
        if x.1 || x.0 > 1_000_000_000_000_000_000 {
            println!("{}", -1);
            return;
        }
        ret = x.0;
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
		int n=str.length();
		if(str.charAt(n-1)!='s') {
			str=str+'s';
		}else if(str.charAt(n-1)=='s') {
			str=str+"es";
		}
		System.out.println(str);
		
	}

}


Measured memory_bytes: 26584
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  int K, S;
  cin >> K >> S;
  
  int ans = 0;
  for (int i = 0; i <= K; ++i) {
    for (int j = 0; j <= K; ++j) {
      int k = S - i - j;
      if (k < 0) continue;
      if (S - i - j <= K) ++ans;
    }
  }

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

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

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

ll func(vector<ll> &w,vector<ll> &v,ll i,ll n,ll val,vector<vector<ll>> &dp)
{
    if(val<=0)
        return 0;
    if(i==n)
        return INT_MAX;
    if(dp[i][val]!=-1)
        return dp[i][val];

    return dp[i][val] = min(func(w,v,i+1,n,val,dp),w[i]+func(w,v,i+1,n,val-v[i],dp));
}

int main(){

    IOS;

    ll t,n,k,m;
    t=1;
    while(t--)
    {
        cin >> n >> k;
        vector<ll> w(n);
        vector<ll> v(n);
        vector<vector<ll>> dp(n+1,vector<ll>(100001,-1));
        for(ll i=0;i<n;i++)
        {
            cin >> w[i] >> v[i];
        }

            for(int i=100000; i>=0; i--)
            {
        		if(func(w,v,0,n,i,dp)<=k)
                {
                    cout << i << endl;
                    break;
                }
        	}
    }
    return 0;
}


Measured memory_bytes: 83192
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int ans=0;
  FOR(i,1,N+1){
    int p=i;
    int temp=0;
    while(p!=0){
      p/=10;
      temp++;
    }
    if(temp%2==1)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
li = input().split()
x = int(li[0])
n = int(li[1])
if n == 0:
    print(x)
else:
    li = list(map(int,input().split()))
    count = 0
    while True:
        if  x - count not in li:
            print(x-count)
            break
        elif x+count not in li:
            print(x+count)
            break 

        count+= 1

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int A[MAXN];
int N,K,zero;

vector<int> neg, pos, realneg;

int rnk(int x){
	//return number of products strictly <= x
	int res=0;
	if (x>=0) res+=(sz(neg)*sz(pos))+(zero*(sz(pos)+sz(neg)))+(zero*(zero-1)/2);
	else{
		for(auto i:neg)	{
			int idx;
			if ((-x)%i==0) idx = LOW(pos,(-x)/i);
			else idx = UP(pos,(-x)/i);
			res += sz(pos)-idx;
		}
		return res;
	}
	if(x==0) return res;
	//int tmp=0;
	FOR(i,0,sz(pos)-1){
		res+=max(0LL, UP(pos,x/pos[i])-i-1);
	}
	FOR(i,0,sz(neg)-1){
		res+=max(0LL, UP(neg,x/neg[i])-i-1);
	}
	return res;
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>K;
	FOR(i,1,N){
		cin>>A[i];
		if (A[i]>0) pos.pb(A[i]);
		if (A[i]<0) neg.pb(-A[i]);
		if (A[i]==0) zero++;
	}
	sort(all(neg));
	sort(all(pos));
	
	int s=-1e18;
	int e=1e18;
	while (e-s>1){
		int m=(s+e)/2;
		if (rnk(m)<K) s=m;
		else e=m;
	}
	cout<<e;
}



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

int main(){
    int n,c=0;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=1;i<n-1;i++){
        if(((p[i]<p[i-1])&&(p[i]>p[i+1]))||((p[i]>p[i-1])&&(p[i]<p[i+1]))){
            c++;
        }
    }
    cout<<c<<endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int h, w;
  cin >> h  >> w;

  vector<string> board(h);
  for (int y = 0; y < h; y++) {
    cin >> board[y];
  }

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      char c = '.';
      if (x == 0) c = '#';
      if (1 <= y && y <= h - 2 && y % 2 == 1 && x != w - 1) {
        c = '#';
      }
      if (board[y][x] == '#') {
        c = '#';
      }
      cout << c;
    }
    cout << endl;
  }

  cout << endl;

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      char c = '.';
      if (x == w - 1) c = '#';
      if (1 <= y && y <= h - 2 && y % 2 == 0 && x != 0) {
        c = '#';
      }
      if (board[y][x] == '#') {
        c = '#';
      }
      cout << c;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N;cin >> N;
    vector<ll> A(N);
    ll m = INF;
    ll ans = 0;
    rep(i,N){
        cin >> A[i];
        if(m >= A[i])ans++;
        m = min(m,A[i]);
    }
    cout << ans << endl;
}

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

int main(){
    string s,t; cin >> s >> t;

    ll ans = 0;
    rep(i,s.size()){
        if(s[i] != t[i]) ans++;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3916
#include <stdio.h>

int main(void){

    int x,y;
    scanf("%d %d",&x,&y);
   

    while(x != 0 || y != 0){
      if( x < y ){
      printf("%d %d\n",x ,y);
      } else {
      printf("%d %d\n",y ,x);
      }
      scanf("%d %d",&x,&y); 
    
    }

    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,cnt = 0;
  int f[31] = {};
  cin >> n >> m;
  for(int i=0;i<n;i++){
    int k, a;
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> a;
      f[a]++;
    }
  }
  for(int i=1;i<=m;i++) cnt += f[i]/n;
  cout << cnt << endl;
}

Measured memory_bytes: 256
#  --*-coding:utf-8-*--

def main():
    N = int(input())
    P = list(map(int, input().split()))

    n = sum(1 for _ in filter(lambda x: x[0] != x[1], zip(P, sorted(P))))
    print('YES' if n <= 2 else 'NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n,m=map(int,input().split())
s,c=[],[]
t=0
for i in range(m):
    a,b=map(int,input().split())
    s.append(a)
    c.append(b)
ans=[10]*n
for i in range(m):
    if ans[s[i]-1]==10:
        ans[s[i]-1]=c[i]
    elif ans[s[i]-1]!=10 and ans[s[i]-1]!=c[i]:
        t=-1
if t==-1:
    print(-1)
elif  n==1 and (ans[0]==0 or ans[0]==10):
    print(0)
elif ans[0]==0:
    print(-1)
else:
    for i in range(n):
        if i==0 and ans[0]==10:
            ans[0]=1
        elif ans[i]==10:
            ans[i]=0
    print(*ans,sep='')

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

int main() {
  ll N, A, B, ans;
  cin >> N >> A >> B;
  if(A>B) swap(A, B);
  if((B-A)%2==0) ans = (B-A)/2;
  else ans =min(A-1,N-B)+1+(B-A-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;

if(n==100000){
       cout << 90909 << endl;
       return 0;
}
string s = to_string(n);
int k = s.size();
if(k==1){
cout << n << endl;
return 0;

}

else if(k==2){
       cout << 9 << endl;
}

else if(k==3){
    cout << 9 + (n-100)+1 << endl;   
}

else if(k==4){
       cout << 9 + 900 << endl;
}

else{
       cout << 909 + n-10000+1 << endl;
       
}

       
}


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

int main() {
string s,t;
cin>>s>>t;
int x=s.length();
int y=t.length();
int dup,maxi=0;
for(int i=0;i<=x-y;i++){
    dup=0;
   int n=0;
   for(int j=i;j<i+y;j++){
        if(s[j]==t[n])dup++;
        n++;
   }
    maxi=max(dup,maxi);
}
cout<<y-maxi;
	return 0;
}

Measured memory_bytes: 3644
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC110.B
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var m = sc.Nextint();
            var x = sc.Nextint();
            var y = sc.Nextint();
            var xa = sc.Arrayint(n);
            var ya = sc.Arrayint(m);

            if (ya.Min() <= xa.Max())
            {
                Console.WriteLine("War");
                return;
            }
            var zCandidate = Enumerable.Range(xa.Max() + 1, ya.Min() - xa.Max())
                .Where(val => val > x)
                .Where(val => val <= y);
            Console.WriteLine(zCandidate.Count() > 0 ? "No War" : "War");
        }
    }
    class Scanner
    {
        string[] s;
        long 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 Nextint()
        {
            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] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13396
from collections import defaultdict

n = int(input())
s = input()

mod = int(1e9+7)

c_map = defaultdict(int)
for c in s:
    c_map[c] += 1

ans = 1
for cnt in c_map.values():
 	if cnt == 1:
 		ans *= 2
 	else:
 		ans *= (cnt+1)

 	if ans > mod:
 		ans %= mod

print(ans-1)


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

int main(void){
	int n;
	string s = "";
	cin >> n;
	if(n==0){
		cout << 0 << endl;
		return 0;
	}
	for(int i=0; i<32; i++){
		if(n==0) break;
		if(n%2==0) s = '0' + s;
		else s = '1' + s;
		if(i%2==0) n -= (n/abs(n))*(n%2);
		if(i%2!=0) n += (n/abs(n))*(n%2);
		n /= 2;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(),(x).end()
#define lowbit(x) x&-x
#define pb emplace_back
#define ls (id<<1)
#define rs (id<<1|1)
#define Rint register int
#define UNI(x) sort(ALL(x)),x.resize(unique(ALL(x))-x.begin())
#define GETPOS(c,x) (lower_bound(ALL(c),x)-c.begin())
#define LEN(x) strlen(x)
#define MS0(x) memset((x),0,sizeof((x)))
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<ll,int> pii;
void _R(int& x){scanf("%d",&x);}
void _R(ll& x){scanf("%lld",&x);}
void _R(db& x){scanf("%lf",&x);}
void _R(char *x){scanf("%s",x);}
void _W(const int &x){printf("%d ",x);}
void _W(const ll &x){printf("%lld ",x);}
void _W(const db &x){printf("%lf ",x);}
void _W(const char *x){printf("%s",x);}
void _WC(const char &x){putchar(x);}
void _WL(){puts("");}
const int MAXN=2e6+10,MAXM=4e6+10;
const int INF=INT_MAX,SINF=0x3f3f3f3f;
const ll llINF=LLONG_MAX;
const int MOD=1e9+7,mod=998244353;
const int inv2=5e8+4;
const int Lim=1<<20;

ll dp[2005][2005],n;

pii a[MAXN];

void solve()
{
    _R(n);
    for(int i=1;i<=n;i++)_R(a[i].fi),a[i].se=i;
    sort(a+1,a+n+1);
    for(int i=n;i;i--)
    {
        for(ll j=0,k=j+i;k<=n+1;j++,k++)
        {
            if(j)dp[j][k]=max(dp[j][k],dp[j-1][k]+a[i].fi*abs(a[i].se-j));
            if(k<=n)dp[j][k]=max(dp[j][k],dp[j][k+1]+a[i].fi*abs(a[i].se-k));
        }
    }
    ll ans=0;
    for(int i=0;i<=n;i++)ans=max(ans,dp[i][i+1]);
    _W(ans);
}

int main()
{
    int T=1;
    //_R(T);
    while(T--)solve();
    return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k;
	cin >> k;
	int sum = 0;
	for (int a = 1; a <= k; a++) {
		//int abc = 0;
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				sum += __gcd(a, __gcd(b, c));
			}
			//abc += __gcd()
		}
	}
	cout << sum << "\n";
	return 0;
}

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

int a[10];
bool avai[10];

signed main(){
    for(register int i=1;i<=9;++i) scanf("%d",&a[i]);

    int n;
    scanf("%d",&n);
    while(n--){
        int x;
        scanf("%d",&x);

        for(register int i=1;i<=9;++i) if(a[i]==x) avai[i]=true;
    }

    bool f=false;
    if((avai[1]&&avai[2]&&avai[3])||(avai[4]&&avai[5]&&avai[6])||(avai[7]&&avai[8]&&avai[9])) f=true;
    if((avai[1]&&avai[4]&&avai[7])||(avai[2]&&avai[5]&&avai[8])||(avai[3]&&avai[6]&&avai[9])) f=true;
    if((avai[1]&&avai[5]&&avai[9])||(avai[3]&&avai[5]&&avai[7])) f=true;

    puts(f?"Yes":"No");

    return 0;
}

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

#define all(v)  begin(v), end(v)
#define endl    '\n';
#define int     long long
#define pii     pair<int, int>
#define sz(x)   (int) x.size()

void test_case() {
    int n;
    cin >> n;

    int cnt = 0, ans = 0;
    int d1, d2;

    for (int i = 0; i < n; i++) {
        cin >> d1 >> d2;
        if (d1 == d2) {
            cnt += 1;
        }
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);

    if (ans >= 3) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

int32_t main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) { 
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3648
S = input()

odd = ('R', 'U', 'D')
even = ('L', 'U', 'D')

ans = 'Yes'
for i in range(1, len(S) + 1):
    if i % 2 == 1:
        if not S[i-1] in odd:
            ans = 'No'
            break
    else:
        if not S[i-1] in even:
            ans = 'No'
            break
print(ans)


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

int main(){
  int N; cin >>N;
  int v[N]; for(int i=0;i<N;i++){cin >> v[i];}
  int c[N]; for(int j=0;j<N;j++){cin >> c[j];}
  int r=0;
  for(int i=0;i<N;i++){
    int temp = v[i]-c[i];
    r += temp*(temp>0);
  }
  
  cout << r << endl;
  
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	 string s,t;cin>>s>>t;
  	if(s.size()+1==t.size()){
      s+=t[t.size()-1];
      if(s==t) 
     cout<<"Yes\n";
      else 
     cout<<"No\n";
    }
  	else {
     cout<<"No\n"; 
    }
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define mod 1000000007
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
inline ll mo(ll a,ll b){if(b<0){b=abs(b)%mod;b=a-b;return (b<0)?b+mod:b;}else{return (a+b)%mod;}}
inline ll pow(ll a,ll b){if(b==0){return 1;}else{if(b%2==0){ll temp=pow(a,b/2);return temp*temp;}
else{return a*pow(a,b-1);}}}

struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        if(p1.first!=p2.first)return p1.first<p2.first;
        else return p1.second<p2.second;
    }
}; 

int main()
{
    fio;
    ll n;cin>>n;
    vvl a(n,vl(3));
    f(n){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    vl dp=a[0];
    for(ll i=1;i<n;i++){
        vl new_dp(3,0);
        for(ll j=0;j<3;j++){
            for(ll k=0;k<3;k++){
                if(j!=k){
                    new_dp[k]=max(new_dp[k],dp[j]+a[i][k]);
                }
            }
        }
        dp=new_dp;
    }
    cout<<max({dp[0],dp[1],dp[2]})<<endl;
}

Measured memory_bytes: 8708
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    L = II()
    assert((L/3)*3 == L)
    print((L/3)**3)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 66028
N=int(input())
tmp=input().split()
T=int(tmp[0])
A=int(tmp[1])
H=input().split()
H=[abs(A-(T-0.006*int(H[i]))) for i in range(0,N)]
min=H[0]
index=0
for i in range(1,N):
    if min>H[i]:
        min=H[i]
        index=i
print(index+1)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int a[2],c=2,d=2,e=2,f=2,i,j;
  for(i=0;i<3;i++){
    scanf("%d%d",&a[0],&a[1]);
    for(j=0;j<2;j++){
  if(a[j]==1) c--;
    if(a[j]==2) d--;
    if(a[j]==3) e--;
    if(a[j]==4) f--;
    }
  }
  if(c==-1||d==-1||e==-1||f==-1)printf("NO\n");
  else printf("YES\n");
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+1);
  for (int i = 0; i <= N; i++) {
    cin >> A.at(i);
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  long a=0;
  for (int i = N; i > 0; i--) {
    if(A.at(i)>B.at(i-1)){
     a+=B.at(i-1);
    }
    else{
      if(A.at(i-1)-(B.at(i-1)-A.at(i))>0){
        A.at(i-1)-=B.at(i-1)-A.at(i);
        a+=B.at(i-1);
      }
      else{
        a+=A.at(i-1)+A.at(i);
        A.at(i-1)=0;
      }
    }
  }
  
 
  cout<<a<<endl;
}





Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll K, S; cin >> K >> S;
	ll cnt = 0;
	repe(i, 0, K) {
		repe(j, 0, K) {
			ll t = S - i - j;
			if (t >= 0 && t <= K) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    //freopen("000.txt","r",stdin);

    ll n,i,j,k,t,s[101],sum=0;

    cin>>n;

    fo(i,n)
    {
        cin>>s[i];
        sum+=s[i];
    }

    sort(s,s+n);
    if(sum%10!=0)
    {
        cout<<sum;
        return 0;
    }
    else
    {
        fo(i,n)
        {
            if((sum-s[i])%10!=0)
            {
                cout<<sum-s[i];
                return 0;
            }

        }
    }

    cout<<0;
    return 0;
}


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

using namespace std;

int main()
{
	long long n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	cout<<(n+min({a,b,c,d,e})-1)/min({a,b,c,d,e})+4<<endl;

	return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
S=["."+input()+"." for i in range(h)]
S=["."*(w+2)]+S+["."*(w+2)]
f=True
for i in range(h):
  for j in range(w):
    if S[i][j]=="#":
      if S[i-1][j]=="." and S[i][j-1]=="." and S[i+1][j]=="." and S[i][j+1]==".":
      	f=False
print("Yes" if f else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
int H, W, C[10][10], A[202][202];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W;
    rep(i, 0, 10) rep(j, 0, 10) cin >> C[i][j];
    rep(y, 0, H) rep(x, 0, W) cin >> A[y][x];
 
    rep(k, 0, 10) rep(i, 0, 10) rep(j, 0, 10) C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
    int ans = 0;
    rep(y, 0, H) rep(x, 0, W) if (0 <= A[y][x]) ans += C[A[y][x]][1];
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   998244353 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   int k , n ;
   cin >>  k >> n ;
   vector < int > a(n) ;
   for( int i = 0 ; i < n ; i++) cin >> a[i] ;
    ll ans = 1e15 ;
   for( int i = 0 ; i < n ; i++){
        ll d = a[i]-a[0] ;
        if(i+1<n){
            d += a[0]+k-a[i+1];
        }
        ans = min(d,ans);
        d = a[n-1]-a[i] ;
        if(i-1>=0){
            d += k-a[n-1] + a[i-1];
        }
        ans = min(d,ans);
   }
   cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,d;
    cin >> n >> d;
    cout << (n + 2 * d) / (2 * d + 1) << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
    L[i]--;
    R[i]--;
  }
  int b[N + 2]{};
  for (int i = 0; i < M; i++) {
    b[L[i]]++;
    b[R[i] + 1]--;
  }
  for (int i = 0; i <= N; i++) {
    b[i + 1] += b[i];
  }
  int cnt = 0;
  for (int i : b) {
    if (i == M) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}
//ヤマカサの競技プログラミングさんの


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn = 10001;

vector<int> G[maxn], ans;
int indegree[maxn], vis[maxn];
int n, e;
void BFS(int s)
{
    queue<int> Q;
    Q.push(s);
    vis[s] = 1;
    while(!Q.empty())
    {
        int top = Q.front();
        ans.push_back(top);
        vis[top] = 1;
        Q.pop();
        for(int i = 0; i < G[top].size(); i++)
        {
            indegree[G[top][i]]--;
            if(indegree[G[top][i]] == 0 && vis[G[top][i]] == 0)
            {
                Q.push(G[top][i]);
            }
        }
    }
}

void topologicalSort()
{
    for(int u = 0; u < n; u++)
        if(indegree[u] == 0 && vis[u] == 0)
            BFS(u);
}

int main()
{
    cin >> n >> e;
    for(int i = 0; i < n; i++)
    {
        vis[i] = 0;
        indegree[i] = 0;
    }
    for(int i = 0; i < e; i++)
    {
        int x, y;
        cin >> x >>y;
        G[x].push_back(y);
        indegree[y]++;
    }
    topologicalSort();
    for(int i = 0; i < ans.size(); i++)
        cout << ans[i] <<endl;
    return 0;
}



Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    int n,ans = 0;
    string s;
    cin >> n >> s;

    for(int i=0; i<n-2; ++i){
        if(s.substr(i,3) == "ABC"){
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int base;
    cin >> base;
    int A,B,C,D;
    A = base/1000;
    base%=1000;
    B = base/100;
    base%=100;
    C = base/10;
    base%=10;
    D = base;
    bool ok = 0;
    REP(l,2){
        REP(s,2){
            REP(y,2){
                int calc = 0;
                if(l == 0){
                    calc = A+B;
                }else{
                    calc = A-B;
                }
                if(s == 0){
                    calc += C;
                }else{
                    calc -= C;
                }
                if(y == 0){
                    calc += D;
                }else{
                    calc -= D;
                }
                if(calc == 7){
                    cout << A << (l ? "-" : "+") << B << (s ? "-" : "+") << C << (y ? "-" : "+") << D << "=7"<< "\n";
                    ok = 1;
                }
                if(ok)break;
            }
            if(ok)break;
        }
        if(ok)break;
    }
}

Measured memory_bytes: 256
#include<iostream>
#define N 1234562*2
using namespace std;

int main(){
  int n;
  bool primeTable[N+1];

  primeTable[0] = primeTable[1] = false;
  for(int i=2;i<=N;i++)primeTable[i] = true;

  for(int pos = 2;pos*pos<=N;pos++){
    if(!primeTable[pos])continue;
    for(int i=pos*2;i<=N;i+=pos){
      primeTable[i] = false;
    }
  }

  while(cin >> n,n){
    int p = 0;
    for(int i=n+1;i<=2*n;i++){ //O(n)
      if(primeTable[i])p++;      //O(1)
    }
    cout << p << endl;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<ll> q;
  rep(i,n){
    ll x; cin >> x;
    q.push(x);
  }
  rep(i,m){
    auto p = q.top(); q.pop();
    q.push(p/2);
  }
  ll ans = 0;
  while(!q.empty()){
    auto p = q.top(); q.pop();
    ans += p;
  }

  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 1400
n = int(input())
lista = list(map(int,input().split()))
m = int(input())
listb = list(map(int,input().split()))
i = 0
j = 0
while True:
    if lista[n-1] < listb[m-1]:
        print('0')
        break
    if lista[i] > listb[j]:
        print('0')
        break
    elif listb[j] == listb[m-1] == lista[i]:
        print('1')
        break
    elif lista[i] < listb[j]:
         i +=1
    elif lista[i] == listb[j]:
         j +=1
         i +=1



Measured memory_bytes: 35280
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
	int a,b,c,i,ans=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0) ans++;
	}
	printf("%d\n",ans );
	return 0;
}

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

class UnionFind {
private:
    std::vector<int> parent;
public:
    UnionFind(int n) : parent(n){
        for(int i = 0; i < n; i++){
            parent[i] = i;
        }
    }
    bool isSame(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        if(parent[x] == x){
            return x;
        }else{
            return parent[x] = root(parent[x]);
        }
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x != y){
            parent[x] = y;
        }
    }
};

int main(){
    int n, m;
    std::cin >> n >> m;
    UnionFind ufGraphs = UnionFind(n+1); // 1-indexed
    int permutation[100010];
    for(int i = 0; i < n; i++){
        int p;
        std::cin >> p;
        permutation[i] = p;
    }
    for(int i = 0; i < m; i++){
        int x, y;
        std::cin >> x >> y;
        ufGraphs.unite(x,y);
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(ufGraphs.isSame(i+1, permutation[i])) cnt++;
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
class Main{
  public static void main(String[] args) throws Exception{
    Scanner sc = new Scanner(System.in);
    StringBuilder sb = new StringBuilder();
    int w = sc.nextInt(), h = sc.nextInt(), q = sc.nextInt();
    char[][] field = new char[w][];
    int[][] x_edge_map = new int[w][], y_edge_map = new int[w][], node_map = new int[w][];
    for(int i = 0; i < w; i++){
      field[i] = sc.next().toCharArray();
      x_edge_map[i] = new int[h];
      y_edge_map[i] = new int[h];
      node_map[i] = new int[h];
    }

    for(int row_index = 0; row_index < field.length; row_index++){
      char[] row = field[row_index];

      for(int index = 0; index < row.length; index++){
        char cell = row[index];
        if(index != 0){
          x_edge_map[row_index][index] = x_edge_map[row_index][index - 1] - (cell == '1' && cell == row[index - 1] ? 1 : 0);
        }
        if(row_index != 0) y_edge_map[row_index][index] = y_edge_map[row_index - 1][index] - (cell == '1' && cell == field[row_index - 1][index] ? 1 : 0);
        node_map[row_index][index] = idx(node_map, row_index, index - 1) + (cell == '1' ? 1 : 0);
      }
    }


    y_accumulation(x_edge_map);
    x_accumulation(y_edge_map);
    y_accumulation(node_map);
    for(int i = 0; i < q; i++){
      int sy = sc.nextInt() - 1, sx = sc.nextInt() - 1, ey = sc.nextInt() - 1, ex = sc.nextInt() - 1;
      sb.append(
      x_edge_map[ey][ex] - idx(x_edge_map,sy-1,ex) - (x_edge_map[ey][sx] - idx(x_edge_map,sy-1,sx)) +
      y_edge_map[ey][ex] - y_edge_map[sy][ex] - (idx(y_edge_map,ey,sx-1) - idx(y_edge_map,sy,sx-1)) +
      node_map[ey][ex] - idx(node_map,sy-1,ex) - (idx(node_map,ey,sx-1) - idx(node_map,sy-1,sx-1))
      );
      sb.append("\n");
    }
    System.out.println(sb);
  }

  private static int idx(int[][] array, int y, int x){
    if(y < 0 || x < 0) return 0;
    return array[y][x];
  }

  private static void y_accumulation(int[][] array){
    for(int i = 1; i < array.length; i++){
      int[] v = array[i];
      for(int j = 0; j < v.length; j++){
        v[j] += array[i - 1][j];
      }
    }
  }

  private static void x_accumulation(int[][] array){
    for(int[] v: array){
      for(int i = 1; i < v.length; i++){
        v[i] += v[i - 1];
      }
    }
  }
}


Measured memory_bytes: 236936
a=input().split()
a=list(map(int,a))
pos = a[1]-1
pal=input()
pal=list(pal)
pal[pos]=pal[pos].lower()
i=1
while i<a[0]:
  pal[0]=pal[0]+pal[i]
  i+=1
print (pal[0])

Measured memory_bytes: 3060
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Created by Harry on 5/10/20.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();
        int[] C = new int[n];
        int[] M = new int[m];
        int[][] A = new int[n][m];
        for(int i=0; i<n; i++){
            C[i] = scanner.nextInt();
            for(int j=0; j<m; j++){
                A[i][j] = scanner.nextInt();
            }
        }
        HashMap<Integer, int[]> map = new HashMap<>();
        HashMap<Integer, int[]> newMap = new HashMap<>();
        map.put(0, new int[m]);
        for(int i=0; i<n; i++){
            for(int prevMask : map.keySet()){
                //0
                int newMask = prevMask<<1;
                int[] newM = new int[m];
                int[] prevM = map.get(prevMask);
                System.arraycopy(prevM, 0, newM, 0, m);
                newMap.put(newMask, newM);
                //1
                newMask = (prevMask<<1)+1;
                newM = new int[m];
                for(int j=0; j<m; j++){
                    newM[j] = prevM[j]+A[i][j];
                }
                newMap.put(newMask, newM);
            }

            HashMap<Integer, int[]> temp = newMap;
            newMap = map;
            map = temp;
            newMap.clear();
        }

        int min = Integer.MAX_VALUE;
        for(int mask : map.keySet()){
            int cost = 0;
            boolean isValid = true;
            int[] curM = map.get(mask);
            for(int b=0; b<n; b++){
                boolean isRead = (mask&(1<<b))>0;
                if(isRead){
                    int actualB = n-1-b;
                    cost += C[actualB];
                }
            }
            for(int algo=0; algo<m; algo++){
                if(curM[algo]<x){
                    isValid = false;
                    break;
                }
            }
            if(isValid){
                min = Math.min(cost, min);
            }
        }
        System.out.print(min==Integer.MAX_VALUE ? -1 : min);
    }
}


Measured memory_bytes: 39620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define Rep(i,a,b) for(int i=a;i<=b;++i)
#define Rrep(i,a,b) for(int i=a;i>b;--i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define sq(a) (a)*(a)
#define nitro std::ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
#define pb push_back
#define pv(x) for(auto y:x)    cout<<y<<" ";    cout<<'\n';
#define fr first
#define sc second
#define ppb pop_back
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define int ll
#define tr(c,it) for(typeof(c.begin()) it= c.begin();it != c.end();it++)
#define ri(X) scanf("%lld", &(X))
#define rii(X, Y) scanf("%lld%lld", &(X), &(Y))
#define riii(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define dri(X) ll (X); scanf("%lld", &X)
#define drii(X, Y) ll X, Y; scanf("%lld%lld", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define rs(X) scanf("%s", (X))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
typedef long long ll;
typedef std::vector< ll > vi;
typedef std::pair<ll, ll> pi;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
        tree_order_statistics_node_update>
        pbds;
const double pie = 3.14159265358979323846;
auto _C=clock();
/*
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;         ;;    ;;     ;;;;;;;     ;;     ;;  ;;;;     ;;
 ;;       ;;   ;;  ;;   ;;    ;;    ;;     ;;  ;; ;;    ;;
  ;;     ;;   ;;    ;;  ;;    ;;    ;;     ;;  ;;  ;;   ;;
   ;;   ;;    ;;;;;;;;  ;;;;;;;     ;;     ;;  ;;   ;;  ;;
    ;; ;;     ;;    ;;  ;;   ;;      ;;   ;;   ;;    ;; ;;
     ;;;      ;;    ;;  ;;    ;;       ;;;     ;;     ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
*/
signed main()
{		
	nitro;
	int CASE=1;
	//ri (CASE);
	//cin>>CASE;
	while(CASE--)
	{
		int x;
		cin>>x;
		if(x) cout<<0<<endl;
		else cout<<1<<endl;
		
	}
	
	
	
	

//cerr<<"\n\n\nTime elapsed: "<<(double)(clock()-_C)*1000.0/CLOCKS_PER_SEC<<"ms\n";		

	return 0;
}



Measured memory_bytes: 3648