akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main()
{   
    string S;
    cin>>S;
    long long ans=0;
    long long ref=0;    
    for(int i=0;i<S.size();i++){
        if(S[i]=='W'){
            ans+=(i-ref);
            ref++;
        }
            
    }
   
    cout<<ans<<endl;


}

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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLine();

            var result = "No";

            if(n[0] == n[2]) {
                result = "Yes";
            }

            Console.WriteLine(result);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13140
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

import numpy as np
import time
import random
start = time.time()
D = int(input())
Cs = np.array(list(mapint()))
Ss = np.array([list(mapint()) for _ in range(D)], dtype=np.float64)
last = np.zeros(26, dtype=np.float64)

lis = []
for i in range(D):
    last_2 = i-last
    last_2.astype(np.float64)
    arr = Ss[i] + Cs*last_2
    idx = np.argmax(arr)
    last[idx] = i+1
    lis.append(idx+1)

def check(Ts):
    last_day = [0]*26
    
    sati = 0
    for i in range(D):
        t = Ts[i]-1
        sati += Ss[i][t]
        last_day[t] = i+1
        for j, l in enumerate(last):
            c = Cs[j]
            sati -= (i+1-l)*c
    return sati

now = check(lis)
while time.time()-start<1.5:
    num = random.randint(0, 364)
    num2 = random.randint(0, 364)
    if num==num2:
        continue
    lis_2 = lis[:]
    lis_2[num], lis_2[num2] = lis_2[num2], lis_2[num]
    nx = check(lis_2)
    if nx>now:
        lis = lis_2
        now = nx

for d in lis:
    print(d)

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

int a,n;

int calc(int p,int q,int aa,int n,int ii)
{
  // cout<<"calc "<<p<<" "<<q<<" "<<aa<<" "<<n<<endl;
  int ans=0;
  if(aa>a)
    return 0;
  if(p<0)
    return 0;
  if(p==0)
    {
      // cout<<"ANS+ "<<p<<" "<<q<<" "<<aa<<" "<<n<<endl;
    return 1;
    }
  if(n<=0)
    return 0;
  
  for(int i=ii;aa*i<=a;i++)
    {
      int pp =i*p-q;
      int qq =i*q;
      
	  if(pp != 0 && qq>=0 && pp>=0 &&  qq%pp==0)
	    {
	      qq=qq/pp;
	      pp=1;
	    }
      
	  ans+=calc(pp,qq,i*aa,n-1,i);
    }

  return ans;

}



int main()
{
  int p,q,n;
  for(;cin>>p>>q>>a>>n,p;)
    {
      int ans=0;
      for(int i=1;i<=a;i++)
	{
	  //	  cout<<"i "<<i<<endl;
	  int pp =i*p-q;
	  int qq =i*q;
	  if(pp != 0 && qq>=0 && pp>=0 &&  qq%pp==0)   
	    {
	      qq=qq/pp;	
	      pp=1;
	    }	  
	  ans+=calc(pp,qq,i,n-1,i);
	}
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
    N10000 = i // 10000
    N1000 = i // 1000 - N10000 * 10
    N100 = i // 100 - N10000 * 100 - N1000 * 10
    N10 = i // 10 - N10000 * 1000 - N1000 * 100 - N100 * 10
    N1 = i - N10000 * 10000 - N1000 * 1000 - N100 * 100 - N10 * 10
    if A <= N1 + N10 + N100 + N1000 + N10000 <= B:
        ans += i
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<stack>
#include<map>
using namespace std;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
#define rep(i,n) for(int i=0; i<n; ++i)
#define repl(i,n,s) for(int i=s; i<=n; ++i)

#define N 1002

typedef pair<int, int> P;

int main() {
  int n, dp[N][N], ans;
  char c;
  stack<P> st;
  while(1) {
    cin >> n;
    if(!n) break;
    ans = 0;
    rep(i, n) {
      rep(j, n) {
        cin >> c;
        if(c == '*') {
          dp[i][j] = 0;
        }else {
          dp[i][j] = i ? dp[i-1][j]+1 : 1;
        }
        int back = j;
        while(!st.empty() && dp[i][j] < st.top().second) {
          if(st.top().first + st.top().second <= j) {
            ans = max(ans, st.top().second);
          }
          back = st.top().first;
          st.pop();
        }
        if(st.empty() || st.top().second < dp[i][j]) {
          st.push(P(back, dp[i][j]));
        }
      }
      while(!st.empty()) {
        if(st.top().first + st.top().second <= n) {
          ans = max(ans, st.top().second);
        }
        st.pop();
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>

int A[1000][1000],b[1000],c[1000];

void reset(){
	int a;
	for(a=0;a<1000;a++){
		c[a]=0;
	}
}

main(void)
{
	reset();
	
	int n,m,c1,c2,i;
	
	scanf("%d %d",&n,&m);
	
	for(c1=0;c1<n;c1++){
		for(c2=0;c2<m;c2++){
			scanf("%d ",&A[c1][c2]);
		}
	}
	
	for(c1=0;c1<m;c1++){
		scanf("%d ",&b[c1]);
	}
	
	for(i=0;i<n;i++){
		for(c1=0;c1<m;c1++){
			c[i]+=A[i][c1]*b[c1];
		}
	}
	
	for(c1=0;c1<n;c1++){
		printf("%d\n",c[c1]);
	}
	return 0;
}

Measured memory_bytes: 1000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int mod=998244353;

int min(int A,int B){
    return A<B?A:B;
}

int main(void){
    int n;
    scanf("%d",&n);
    char s[n+3];
    scanf("%s",s);
    int countblack[200001]={},countwhite[200001]={};
    
    
    for (int i=0; i<strlen(s); i++){
        if (i==0){
            if(s[i]=='#'){
                countblack[i]=1;
            }
        } else {
            countblack[i]=countblack[i-1];
            if(s[i]=='#'){
                countblack[i]++;
            }
        }
    }
    
    
    for (int i=strlen(s)-1; i>=0; i--){
        if (i==strlen(s)-1){
            if(s[i]=='.'){
                countwhite[i]=1;
            }
        } else {
            countwhite[i]=countwhite[i+1];
            if(s[i]=='.'){
                countwhite[i]++;
            }
        }
    }
    int ans=n;
    for (int i=0; i<n; i++){
        ans=min(ans,countblack[i]+countwhite[i]-1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define lli long long int
#define ld long double
#define pb push_back
#define is insert
#define iamspid ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    iamspid
    lli n, w;
    cin>>n>>w;
    lli wt[n+1], val[n+1];
    lli vs=0;
    for(lli i=1;i<=n;i++)
    {
        cin>>wt[i]>>val[i];
        vs=vs+val[i];
    }
    vector<lli> dp(vs+1, 1000000000);
    dp[0]=0;
    lli m=0;
    for(lli i=1;i<=n;i++)
    {
        for(lli j=vs-val[i];j>=0;j--)
        {
            dp[j+val[i]]=min(dp[val[i]+j], dp[j]+wt[i]);
            if(dp[j+val[i]]<=w) m=max(m, val[i]+j);
        }
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define LB(vec,n) lower_bound(vec.begin(),vec.end(),n)
using namespace std;

int main(){
	while(true){
		int n,l;cin >> n >> l;
		if(n == 0)break;
		vector<pair<char,int> > ant(n);
		int anstime = 0;
		for(int i = 0; i < n; ++i){
			char d; cin >> d;
			int p; cin >> p;
			pair<char,int> pa(d,p);
			ant[i] = pa;
		}
		int time = 0;
		//for(int i = 0; i < n; ++i){	cout << ant[i].first << " " << ant[i].second << endl;}
		while(true){
			//if(time == 1)break;
			bool flag = true;
			for(int i = 0; i < n; ++i){
				if(ant[i].first == 'L' && ant[i].second> 0){
					flag = false;
					break;
				}
				else if(ant[i].first == 'R' && ant[i].second < l){
					flag = false;
					break;
				}
			}
			if(flag)break;
			for(int i = 0; i < n; ++i){
				if(ant[i].first == 'L'){
					ant[i].second--;
				}
				else{
					ant[i].second++;
				}
			}
			for(int i = 0; i < n-1; ++i){
				for(int j = i+1; j < n; ++j){
					if(ant[i].second == ant[j].second){
						swap(ant[i].first, ant[j].first);
					}
				}
			}
			time++;
		}
		//for(int i = 0; i < n; ++i){	cout << ant[i].first << " " << ant[i].second << endl;}
		int rlast =200, llast = -100;
		int rnum,lnum;
		for(int i = 0; i < n; ++i){
			if(ant[i].first == 'L' && ant[i].second > llast ){
				llast = ant[i].second;
				lnum = i+1;
			}
			else if(ant[i].first == 'R' && ant[i].second < rlast){
				rlast = ant[i].second;
				rnum = i+1;
			}
		}
		cout << time << " ";
		if(llast >= l - rlast){
			cout << lnum << endl;
		}
		else{
			cout << rnum << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 3108
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    let n: usize = 2;
    input!{
        v: [usize;n],
    }

    println!("{}", v[0]*(v[0]-1)/2 + v[1]*(v[1]-1)/2);

}

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

const ll INF = 1LL << 60;

ll N, K;
vector<ll> A;
int main() {
    cin >> N >> K;
    A.resize(N);
    rep(i, N) cin >> A[i];
    
    // 最終的には全て1になる
    // ll left = ceil((double)idx / (K - 1));  
    // ll right = ceil((double)(N - idx - 1) / (K - 1));  
    // ans = left + right;
    cout << ceil((double)(N - 1) / (K - 1)) << endl;
}

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

#define ll long long
#define ar array

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

	string s;
	cin >> s;
	cout << (s[2]==s[3]&&s[4]==s[5]?"Yes":"No");
}

Measured memory_bytes: 256
s = input()
s = [int(i) for i in s]
n = len(s)
start_one = []
start_zero = []
for i in range(n):
    if i % 2 == 0:
        start_one.append(1)
        start_zero.append(0)
    else:
        start_one.append(0)
        start_zero.append(1)
count_one = 0
count_zero = 0
for i in range(n):
    if s[i] != start_one[i]:
        count_one += 1
    elif s[i] != start_zero[i]:
        count_zero += 1
ans = min(count_one, count_zero)
print(ans)

Measured memory_bytes: 5528
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll n = s.size();
    map<char, ll> mp;
    ll ans = 0;
    rep(i, s.size())
    {
        ans += i - mp[s[i]];
        mp[s[i]]++;
    }
    cout << 1 + ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
typedef unsigned long long ULL;

ULL gcd(ULL a, ULL b);
ULL lcm(ULL a, ULL b);

int main(){
    ULL a, b, c, d;
    scanf("%llu %llu %llu %llu", &a, &b, &c, &d);

    b = b - b / c - b / d + b / lcm(c, d);
    a = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d);

    printf("%llu\n", b - a);
    return 0;
}

ULL gcd(ULL a, ULL b){
    return ((b != 0) ? gcd(b, a % b) : a);
}

ULL lcm(ULL a, ULL b){
    return a * b / gcd(a, b);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,m;
vector<int>v[100001];
ll  dp[100001];
ll  res;
ll  dfs(int x)
{
	if(dp[x]!=0)
	return dp[x];
	for(int i=0;i<v[x].size();i++)
	{
		res=1+dfs(v[x][i]);
		dp[x]=max(dp[x],res);
	}
	return dp[x];
}
int main()
{
	cin>>n>>m;
	 ll x,y,res1=0;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
	{
		res1=max(res1,dfs(i));
	}
	cout<<res1<<"\n";
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in();
	vector<int>a(n);
	REPC(&i, a)i = in();
	int cnt = 0;
	REP(i, n)
	{
		int min_index = i;
		REPI(j, i, n)
		{
			if (a[min_index] > a[j])
			{
				min_index = j;
			}
		}
		if (i != min_index)
		{
			swap(a[i], a[min_index]);
			cnt++;
		}
	}
	REP(i, n)
	{
		if (i != 0)cout << ' ';
		cout << a[i];
	}
	cout << endl;
	cout << cnt << endl;
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){
 string s;
  int k;
  cin>>s>>k;
  for(int i=0;i<s.size();i++){
   if(s[i]=='1'){
     k--;
     if(k<=0) {
       cout<<s[i];
       break;
     }
  	}
    else {
    	cout<<s[i];
    	break;
	}
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
  	ll k,a,b;
  	cin >> k>> a >> b;
	for(ll i=a;i<=b;i++){
    	if(i%k==0){
            cout << "OK"<<endl;
            return 0;
        }
    }
  	cout << "NG" << endl;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main() {
    string S; cin >> S;
    int cnt[26] = {};
    for(int i = 0; i < S.size(); i++) {
        if(++cnt[S[i]-'a'] > 1) {
            cout << "no";
            return 0;
        }
    }
    cout << "yes";
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define Yes cout << "Yes" << endl ;
#define yes cout << "yes" << endl ;
#define No cout << "No" << endl ;
#define no cout << "no" << endl ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio

    lli ab , bc , ca , area = 0 ;
    cin >> ab  >> bc >> ca ;

    area = (ab * bc ) /  2 ;

    cout << area << endl ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/


Measured memory_bytes: 256
import copy
A = list()
n, m = map(int, input().split())
for i in range(m):
    a = list(map(int, input().split()))
    A.append(a)
    A.append([a[1], a[0]])

B = list()

def update(current=[1], rest=A, count = 0):
    next = list(filter(lambda x: x[0] == current[count], rest))
    if len(current) < n:
        for ne in next:
            l = copy.deepcopy(current)
            l.append(ne[1])
            nRest = list(filter(lambda x: x[0] != current[count] and x[1] != current[count] and x[1] != ne[1], rest))
            update(l, nRest, count + 1)
    else:
        B.append(current)

update()
print(len(B))

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> color(9, 0);
    for(int i=0; i<n; i++) {
        int ai;
        cin >> ai;
        if(ai<400) {
            color[0] = 1;
        } else if(ai<800) {
            color[1] = 1;
        } else if(ai<1200) {
            color[2] = 1;
        } else if(ai<1600) {
            color[3] = 1;
        } else if(ai<2000) {
            color[4] = 1;
        } else if(ai<2400) {
            color[5] = 1;
        } else if(ai<2800) {
            color[6] = 1;
        } else if(ai<3200) {
            color[7] = 1;
        } else {
            color[8] += 1;
        }
    }
    int c = 0;
    for(int i=0; i<8; i++) {
        c += color[i];
    }

    int max_c = 0;
    if(c>0) {
        max_c = c+color[8];
    } else {
        c = 1;
        max_c = color[8];
    } 
    cout << c << " " << max_c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int num,mid,one,num2;
  int i,j;

  scanf("%d",&num);

  int array[num][num];
  for(i = 0;i < num;i++){
    for(j = 0;j < num;j++){
      array[i][j] = 0;
    }
  }

  for(i = 0;i < num;i++){
    scanf("%d%d",&one,&mid);
    for(j = 0;j < mid;j++){
      scanf("%d",&num2);
      array[one - 1][num2 - 1] = 1;
    }
  }

  for(i = 0;i < num;i++){
    for(j = 0;j < num;j++){
      if(j != 0)printf(" ");
      printf("%d",array[i][j]);
    }
    printf("\n");
  }

  return 0;
   
}

Measured memory_bytes: 636
m,n=map(int,input().split())
hoge=[[0 for i in range(n+2)] for j in range(m+2)]
for i in range(m):
  sss=input()
  for j in range(n):
    if(sss[j]=="#"):
      hoge[1+i][1+j]=1
    

flag=True
for i in range(m):
  for j in range(n):
    if(hoge[1+i][1+j]==1):
      ans=0
      #print(1+i,1+j,ans,hoge[i][1+j],hoge[1+i][j],hoge[2+i][1+j],hoge[1+i][2+j])
      ans=max(hoge[i][1+j],hoge[1+i][j],hoge[2+i][1+j],hoge[1+i][2+j])
      if(ans==0):
        flag=False
        
if(flag):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def group_cnt(self):  # グループの数
        return sum(x < 0 for x in self.parents)

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uf = Unionfind(n)
for a, b in ab:
    uf.union(a - 1, b - 1)
print(uf.group_cnt() - 1)


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

int main() {
	int n,m,ans_1,ans_2;
	cin>>n>>m;
	if(n>1){
	    ans_1=n*(n-1)/2;
	}
	else{
	    ans_1=0;
	}
	if(m>1){
	    ans_2=m*(m-1)/2;
	}
	else{
	    ans_2=0;
	}
	cout<<ans_2+ans_1;
	return 0;
}

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

typedef long long ll;
const ll INF = 1e18;

ll mn[2100][2100];

int main() {
	ll N, x;
	cin >> N >> x;
	vector<ll> a(N);
	for(int i = 0; i < N; i++) cin >> a[i];
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			mn[i][j] = INF;

	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			if(j == 0)
				mn[i][j] = a[i];
			else
				mn[i][j] = min(a[(i-j+N)%N], mn[i][j-1]);
		}
	}
	ll res = INF;
	for(int i = 0; i < N; i++) {
		ll tmp = 0;
		for(int j = 0; j < N; j++) {
			tmp += mn[j][i];
		}
		tmp += i*x;
		res = min(res, tmp);
	}
	cout << res << endl;
}


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

int main() {
	int A,B;cin>>A>>B;
	if(A > B)swap(A, B);
	if(A == B)cout<<A+B<<endl;
	else cout<<2*B-1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

void solve() {
    indef(i32, n, k);
    vec<i32> l(n);
    times(n, i) {
        in(l[i]);
    }
    sortall(l);
    i32 ans = 0;
    times(k, i) {
        ans += l[n-1-i];
    }
    out(ans);
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    //cout << fixed << setprecision(9);
    solve();
    return 0;
}

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

int main() {
    int a;
    int five = 0;
    int seven = 0;
    for (int i = 0; i < 3; i++) {
        cin >> a;
        if (a == 5) five++;
        else if (a == 7) seven++;
    }
    cout << ((five == 2 && seven == 1) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
S = input()
nQ_r = S.count('?')
nC_r = S.count('C')
nQ_l = 0
nA_l = 0
N = len(S)
mod = 10**9+7

pow3 = [1]*N
p = 1
for i in range(1,N):
    pow3[i] = p = p*3%mod

ans = 0
for n, c in enumerate(S):
    if c=='C': nC_r-=1
    if c=='?': nQ_r-=1
    
    if n>0 and n<N-1 and (c=='B' or c=='?'):
        p = ( nQ_l*pow3[max(0, nQ_l-1)] + nA_l*pow3[nQ_l] ) % mod
        q = ( nQ_r*pow3[max(0, nQ_r-1)] + nC_r*pow3[nQ_r] ) % mod
        ans += p * q
        ans %= mod

    if c=='A': nA_l+=1
    if c=='?': nQ_l+=1

print(ans)

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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;
 
int main() {
    ios_base::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < 3; i++) if(s[i] == t[i]) ans++;
    cout << ans << endl;
    return 0;
}



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

int main() {
  int X;
  cin >> X;
  for (int a = -200; a < 200; a++) {
    for (int b = -200; b < 200; b++) {
      if (pow(a,5)-pow(b,5)==X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4080
n,m=map(int,input().split())
A=[list(input()) for i in range(n)]
B=[list(input()) for i in range(m)]
flag=0
for i in range(n-m+1):
  for j in range(n-m+1):
    C=A[i:i+m]
    for k in range(m):
      C[k]=C[k][j:j+m]
    if C==B:
      flag=1
print("Yes" if flag==1 else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
	ll n; cin >> n;
	ll a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << ll(5) + (n - 1) / (min({a, b, c, d, e})) << endl;
    return 0;
}


Measured memory_bytes: 3580
use proconio::input;

fn main() {
    input!(n:i32,k:i32);
    let mut hs = std::collections::HashSet::new();
    for _ in 0..k {
        input!(d:i32);
        for _ in 0..d {
            input!(e:i32);
            hs.insert(e);
        }
    }
    println!("{}",n - hs.len() as i32);
}


Measured memory_bytes: 2188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   int x = 0;
   int n,max = 0;
   char s[101];scanf("%d %s",&n,s);
   for(int i = 0;i < n;i++){
      if(s[i] == 'I')x++;
      else x--;
      max = MAX(x,max);
   }
   printf("%d",max);
}

Measured memory_bytes: 128
const Main = (input) => {
        const dataArray = input.split('\n');
  		const strength = dataArray[0].split(' ')[0];
  		const deathblowType = dataArray[0].split(' ')[1];
		const deathblowList = dataArray[1].split(' ').map(Number);
  		var totalAttack = 0;
  
  for (var i = 0; i < deathblowType; i ++){
    totalAttack += deathblowList[i];
  }
  if (totalAttack >= strength) {
    console.log('Yes');
  } else {
    console.log('No');
  }
    }

    Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 16716
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(a * b)
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int x = tx - sx;
    int y = ty - sy;
    for(int i=0;i<y;i++) cout << 'U';
    for(int i=0;i<x;i++) cout << 'R';
    for(int i=0;i<y;i++) cout << 'D';
    for(int i=0;i<x;i++) cout << 'L';
    cout << 'L' ;
    for(int i=0;i<=y;i++) cout << 'U';
    for(int i=0;i<=x;i++) cout << 'R';
    cout << "DR";
    for(int i=0;i<=y;i++) cout << 'D';
    for(int i=0;i<=x;i++) cout << 'L';
    cout << 'U'<<endl;
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
h = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))

price_min = min(a) + min(b)
for i in range(h[2]):
  c = list(map(int,input().split()))
  price = a[c[0]-1] + b[c[1]-1] - c[2]
  if price_min > price:
    price_min = price
    
print(price_min)

Measured memory_bytes: 18736
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <string>

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

using pii = pair<i32, i32>;

#define rep(i, n) for (i32 i = 0; i < (n); ++i)
#define repr(i, n) for (i32 i = ((n)-1); i >= 0; --i)
#define urep(i, n) for (u32 i = 0; i < (n); ++i)
#define urepr(i, n) for (u32 i = ((n)-1); i >= 0 && i < (n); --i)
#define all(v) v.begin(), v.end()

int N;
vector<int> arr(100000);

int main()
{

	cin >> N;
	rep(i, N) cin >> arr[i];

	sort(arr.begin(), arr.begin() + N);

	int middle = N / 2;
	cout << (arr[middle] - arr[middle - 1]) << endl;

	return 0;
}


Measured memory_bytes: 640
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func modPow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if (n & 1) > 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func main() {
	mod := int(1e+9) + 7
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	// no bit
	S := make([]int, 60)
	// bit
	M := make([]int, 60)
	for i := 0; i < N; i++ {
		for j := 0; j < 60; j++ {
			if A[i]&(1<<uint(j)) == 0 {
				S[j]++
			} else {
				M[j]++
			}
		}
	}
	ans := 0
	for i := 0; i < 60; i++ {
		ans += (S[i] * M[i]) % mod * modPow(2, i, mod)
		ans %= mod
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 6784
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> pidx(N, 0);
	vector<pair<double, double>> plist(N, make_pair(0.0, 0.0));
	for (int i = 0; i < N; i++)
	{
		cin >> plist[i].first >> plist[i].second;
		pidx[i] = i + 1;
	}

	vector<vector<double>> dist(N, vector<double>(N, 0.0));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (i == j) continue;

			dist[i][j] = hypot(plist[i].first - plist[j].first, plist[i].second - plist[j].second);
		}
	}

	double accum = 0.0;
	double count = 0.0;
	do
	{
		for (int i = 0; i < N - 1; i++)
		{
			accum += dist[pidx[i] - 1][pidx[i + 1] - 1];
		}
		count += 1.0;
	} while (next_permutation(pidx.begin(), pidx.end()));

	cout.setf(ios::fixed);
	cout.precision(7);
	cout << accum / count;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 998244353;

int digit (int a) {
  int res = 0;
  while (a >= 10) {
    res += a % 10;
    a -= a % 10;
    a /= 10;
  }
  res += a;
  return res;
}

int main() {
  int N;
  cin >> N;
  int ans = 9999999;
  for (int i = 1; i <= N-1; i++) {
    int a = digit(i) + digit(N-i);
    ans = min(ans,a);
  }
  cout << ans << endl;
  return 0;
}

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

#define INF (1<<18)



int main() {
    string str;
    cin>>str;

    int l = str.length();
    int s[l];
    rep(i,l) s[i] = str[l-i-1]-'0';



    ll ans = 0; 
    ans += s[0]*(1<<l-1);

    rep(i,1 << l-1 ){
        int b = 0;
        rep(j,l-1){
            if((i >> j)&1){
                b = j+1;
            }
            ans += s[j+1]*pow(10,j+1-b);
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
import scala.io.{StdIn => in}

object Main extends App {
  val mod = 2019L
  val Array(l, r) = in.readLine.split(" ").map(_.toLong)

  var res = Int.MaxValue + 1L
  for{
    i <- 0L until mod
    if l + i < r
    j <- (i + 1L) until (i + 1L + mod)
    if l + j <= r
  } {
    val v = ((l+i) * (l+j)) % mod
    if(res > v) res = v
  }

  val ans = res
  println(ans)
}

Measured memory_bytes: 55284
#include <bits/stdc++.h>
				using namespace std;
				#define ll long long
				#define mod 1000000007
				#define pll pair<long,long>
				#define se second
				#define fi first
				#define pb push_back
				#include <ext/pb_ds/assoc_container.hpp>
				#include <ext/pb_ds/tree_policy.hpp>
				using namespace __gnu_pbds;

				typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
				typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;
				
			
				
				int main()
				{
					ios_base::sync_with_stdio(false);
					cin.tie(NULL);
					
					ll n;
					cin>>n;
					vector<ll> v(n);
					map<ll,ll> m;
					for(ll i=0;i<n;i++)
					{
						cin>>v[i];
						m[v[i]]++;
					}
					ll ans=0;
					for(auto i:m)
					{
						ans+=i.se*(i.se-1)/2;
					}
					for(ll i=0;i<n;i++)
					{
						cout<<ans-(m[v[i]]-1)<<endl;
						
					}
				}
				


Measured memory_bytes: 11272
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n, m;
	while (cin >> n >> m, n)
	{
		int cost[105][105]; int time[105][105];
		REP(i, m)REP(j, m)
		{
			if (i == j)
			{
				cost[i][j] = 0;
				time[i][j] = 0;
			}
			else
			{
				cost[i][j] = INF;
				time[i][j] = INF;
			}
		}
		int a, b, c, t;
		REP(i, n)
		{
			cin >> a >> b >> c >> t;
			a--; b--;
			cost[a][b] = c; cost[b][a] = c;
			time[a][b] = t; time[b][a] = t;
		}
		REP(k, m)REP(i, m)REP(j, m)
		{
			cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
			time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
		}
		int	q;
		cin >> q;
		REP(i, q)
		{
			cin >> a >> b >> c;
			a--; b--;
			if (c) cout << time[a][b] << endl;
			else cout << cost[b][a] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int n;
	while(cin>>n){
		if(n==0) break;
		vi v(n,0);
		rep(i,n){
			cin>>v[i];
		}
		sort(all(v));
		int mi=INF;
		rep(i,n-1){
			if(mi>abs(v[i]-v[i+1])){
				mi=abs(v[i]-v[i+1]);
			}
		}
		cout<<mi<<endl;
	}
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int MXN=3000;
int a[MXN+1];
int dp[MXN+1][MXN+1][2];
bool vis[MXN+1][MXN+1][2];
int n,k;
int solve(int l,int r,int k){
	if( l==r )return dp[l][r][k]=(k ? -1*a[l] : a[l]);
	if( vis[l][r][k] )return dp[l][r][k];
	vis[l][r][k]=1;
	if(k==0){
		dp[l][r][k]=max(a[r]+solve(l,r-1,k^1),a[l]+solve(l+1,r,k^1));
	}
	else {
		dp[l][r][k]=min(-a[r]+solve(l,r-1,k^1),-a[l]+solve(l+1,r,k^1));
	}
	return dp[l][r][k];
}

int32_t main()
{
   IOS
   memset(dp,0,sizeof(dp));
   memset(vis,false,sizeof(vis));
   cin >> n ;
   for(int i=1;i<=n;i++)
   cin>>a[i];
   cout << ( solve(1,n,0) ) << endl;
}


Measured memory_bytes: 158720
#include <stdio.h>

int main(void) {
	int n, i;
	int minv, maxv, tmp;

	scanf("%d", &n);
	scanf("%d", &minv);
	maxv = -999999999;
	for (i = 1; i < n; ++i) {
		scanf("%d", &tmp);
		maxv = (maxv > (tmp - minv)) ? maxv : (tmp - minv);
		minv = (minv > tmp) ? tmp : minv;
	}
	printf("%d\n", maxv);
	
	return 0;
}

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


void solve(long long A, long long B, long long T){
    cout << (T / A) * B << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long T;
    scanf("%lld",&T);
    solve(A, B, T);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <cstddef>
#include<queue>
using namespace std;

int main()
{
    int N, K, f = 0;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0; i < N; i++)
    {
        cin >> h.at(i);
        if(h.at(i) >= K) f++;
    }
    cout << f << endl;
    return 0;
}


Measured memory_bytes: 640
n,y = map(int,input().split())
for a in range(n + 1):
    for b in range(n + 1):
        c = n - (a+b)
        if 10000*a + 5000*b + 1000*c == y and c>=0:

                print(a,b,c)
                exit()
print(-1,-1,-1)
            
           



Measured memory_bytes: 3064
#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 lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;
    vector<lli> v;
    lli val = 0;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        val ^= a;
        v.pb(a);
    }

    for (lli i = 0; i < n; i++) {
        lli ans = val ^ v[i];
        cout << ans << " ";
    }
    cout << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 5324
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

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


int main() {
	int ans=0;

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

	//vectorの配列定義は（）かっこで、実際に使う時は[]括弧のようだ
	vector<int> ctnx(h),ctny(w);//各行・各列にある爆弾の数
	//vector<int> ctnx,ctny;														//要素数を定義しなくても使える？こっちだとセグフォ
  set<P> bomb;//各爆弾の座標

	int tmpx,tmpy;
	rep(i,m){
		cin >> tmpx >> tmpy;//配列要素数にも使うため、一旦変数として受け取る必要がある。
		--tmpx;--tmpy;
		ctnx[tmpx]+=1;
		ctny[tmpy]+=1;
    bomb.emplace(tmpx,tmpy);
	}

	//各行・列ごとに爆弾の最大個数を探す
	int max_ctnx=-1;
	int max_ctny=-1;
	rep(i,h){
		if(max_ctnx < ctnx[i]) max_ctnx=ctnx[i];
	}
	rep(i,w){
		if(max_ctny < ctny[i]) max_ctny=ctny[i];
	}

	//爆弾の最大個数と一致する、行・列を抽出
	vector<int> max_bombx,max_bomby;//要素数の最大は爆弾の個数M
	rep(i,h){
		if(max_ctnx == ctnx[i]) max_bombx.push_back(i);
	}
	rep(i,w){
		if(max_ctny == ctny[i]) max_bomby.push_back(i);
	}

	//行・列のうち、爆弾のない所が見つかればansは、max_ctnx+max_ctny個、そうでなければ1個を減らす
	ans = max_ctnx+max_ctny;
	rep(i,max_bombx.size())
		rep(j,max_bomby.size()){
			//cout << "i,j	" << i << ",	" << j <<endl;
			tmpx=max_bombx[i];
			tmpy=max_bomby[j];

			if(bomb.count(P(tmpx,tmpy))) continue;
			cout << ans << endl;
			return 0;
		//bomb[i].first=1;

	}
	//for (int i : max_bombx) for (int j : max_bomby) {//iはmaxbombxの要素を試す。
	//		cout << "i,j	" << i << ",	" << j <<endl;
	//		if(bomb.count(P(i,j))) continue;
	//		cout << ans << endl;
	//		return 0;
	//}

  --ans;
	//cout << "hoge:" <<ans << endl;
	cout <<ans << endl;
	return 0;
	//rep(i,n)

}

Measured memory_bytes: 23848
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            int a;
            cin>>a;
            a--;
            h[a]=1;
        }
    }
    int ans=0;
    rep(i,n){
        if(h[i]==0)ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N, K;
int b[4010][4010], w[4010][4010];

template <int n, int m>
inline int safeAt(int (&a)[n][m], int x, int y, int d){
    if(0 <= x && x < m && 0 <= y && y <= n){
        return a[y][x];
    }
    return d;
}

// (x, y)を右下に持つ1辺Kの正方形内の値の和
int sum(int (&a)[4010][4010], int y, int x){
    int x1 = x - 1, y1 = y - 1, x2 = x1 + K, y2 = y1 + K;

    return safeAt(a, x2, y2, 0) - safeAt(a, x1, y2, 0) - safeAt(a, x2, y1, 0) + safeAt(a, x1, y1, 0);
}

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

    std::cin >> N >> K;
    int L = 2 * K;
    
    for(int i=0;i<N;++i){
        int x, y;
        char c;
        std::cin >> x >> y >> c;

        x %= L;
        y %= L;
        
        if(c == 'W'){
            for(int j=0;j<2;++j){
                for(int k=0;k<2;++k){
                    ++w[y + L * j][x + L * k];
                }
            }
        }else{
            for(int j=0;j<2;++j){
                for(int k=0;k<2;++k){
                    ++b[y + L * j][x + L * k];
                }
            }
        }
    }

    for(int i=0;i<2*L;++i){
        for(int j=0;j+1<2*L;++j){
            w[i][j+1] += w[i][j];
            b[i][j+1] += b[i][j];
        }
    }

    for(int j=0;j<2*L;++j){
        for(int i=0;i+1<2*L;++i){
            w[i+1][j] += w[i][j];
            b[i+1][j] += b[i][j];
        }
    }

    int res = 0;
    for(int i=0;i<L;++i){
        for(int j=0;j<L;++j){
            int x = sum(b, i, j) + sum(b, i + K, j + K) + sum(w, i + K, j) + sum(w, i, j + K);
            // std::cout << i << ", " << j << ", " << x << std::endl;
            res = max(res, x);
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 125696
import sys
sys.setrecursionlimit(10**7)
n,m = map(int, input().split())
adjacent_list = [[] for i in range(n+1+m+1)]
for i in range(1,n+1):
    for j in list(map(int, input().split()))[1:]:
        adjacent_list[i].append(j+n)
        adjacent_list[j+n].append(i)
finished = set()
def dfs(node):
    finished.add(node)
    for i in adjacent_list[node]:
        if i not in finished:
            dfs(i)
dfs(1)
flag = True
for i in range(1,n+1):
    if i not in finished:
        flag = False
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 41412
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
const double PI = 3.141592653589;

int main() {
    double r;  cin >> r;
    printf("%f %f\n", PI*r*r, 2*PI*r);
}


Measured memory_bytes: 3164