akhauriyash/Code-Regression huggingface dataset:
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.head.split(' ').map(_.toInt)
  val A = ls(0)
  val B = ls(1)
  val C = ls(2)
  val ret = if((A<C && C<B)||(B<C && C<A)) "Yes" else "No"
  println(ret)
}


Measured memory_bytes: 25548
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int x,y,z;
    cin>>x>>y>>z;
    x-=z;
    int counter=0;
    counter+=x/(y+z);
    printf("%d\n",counter);
}

Measured memory_bytes: 256
s = input()
size = len(s)
if size == 2:
    if s[0] == s[1]:
        print("1 2")
    else:
        print("-1 -1")
else:
    for i in range(2, size):
        a = s[i]
        b = s[i-1]
        c = s[i-2]
        if a == b or b == c or a == c:
            print(i-1, i+1)
            break
    else:
        print("-1 -1")

Measured memory_bytes: 9216
#include <iostream>

int main()
{
    char c;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> c;
            if (i == j) {
                std::cout << c;
            }
        }
    }

    std::cout << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  std::vector<int64_t> a(3*n);
  for(int i=0;i<3*n;i++){
    cin>>a[i];
  }

  int64_t cum[300001]={};
  cum[0]=a[0];
  for(int i=1;i<3*n;i++){
    cum[i]=cum[i-1]+a[i];
  }

  std::priority_queue<int64_t,std::vector<int64_t>,std::greater<>> left;
  std::priority_queue<int64_t,std::vector<int64_t>> right;
  int64_t left_omit_sum[300001]={},right_omit_sum[300001]={};
  for(int i=0;i<n;i++){
    left.push(a[i]);
  }
  for(int i=n;i<3*n;i++){
    left.push(a[i]);
    left_omit_sum[i]=left_omit_sum[i-1]+left.top();
    left.pop();
  }
  for(int i=3*n-1;i>=2*n;i--){
    right.push(a[i]);
  }
  for(int i=2*n-1;i>=0;i--){
    right.push(a[i]);
    right_omit_sum[i]=right_omit_sum[i+1]+right.top();
    right.pop();
  }

  int64_t result=-INT64_MAX;
  for(int i=n-1;i<2*n;i++){
    int64_t left_sum=cum[i]-left_omit_sum[i];
    int64_t right_sum=cum[3*n-1]-cum[i]-right_omit_sum[i+1];
    result=std::max(result,left_sum-right_sum);
  }

  cout<<result<<endl;


  
  return 0;
}


Measured memory_bytes: 12020
n,m = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
N = 10**9+7
Lx=0
Ly=0
for i in range(n):
    Lx += (-n+2*i+1)*x[i]
    Lx %= N
for i in range(m):
    Ly += (-m+2*i+1)*y[i]
    Ly %= N
ans = Lx*Ly%N
print(ans)

Measured memory_bytes: 18684
n,m=map(int,input().split())
fig=[0 for _ in range(n)]
fig[0]=1
f=[0 for _ in range(n)]

if n==1 and m==0:
  print(0)
  exit()

for i in range(m):
  s,c=map(int,input().split())
  if f[s-1]==1 and fig[s-1]!=c:
    print(-1)
    exit()
  else:
    f[s-1]=1
    fig[s-1]=c
if fig[0]==0 and n>=2:
  print(-1)
  exit()
ans=0
for i in range(n):
  ans+=fig[i]*(10**(n-i-1))


print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
//ai*log(ai);
//solve dynamic programming problems
//dp with bitmasks
vector< vector<int> > p;
int answer=0;
void permute(int s[],int l,int r,int n)
{
	if(l==r)
	{
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			ans+=p[i][s[i]];
		}
		answer=max(answer,ans);
	}
	else
	{
		for(int i=l;i<=r;i++)
		{
			swap(s[i],s[l]);
		permute(s,l+1,r,n);
		swap(s[i],s[l]);	
		}
	}
}
const int MOD=1e9+7;
int countbit(int mask)
{ int count=0;
	while(mask)
	{
		if(mask%2)count++;
		mask=mask/2;
	}
	return count;
}
signed main()
{
  int n;cin>>n;
  int a[n+1][n+1];
  for(int i=0;i<n;i++)
  for(int j=0;j<n;j++)
  cin>>a[i][j];
  int powe[n]={0};
  powe[0]=1;
  //cout<<"OK"<<endl;
  for(int i=1;i<=n;i++)
  {
  	powe[i]=powe[i-1]*2;
  }
 int dp[powe[n]+1]={0};
 dp[0]=1;
 for(int mask=0;mask<powe[n];mask++)
 { 
 int k=countbit(mask);
 	for(int j=0;j<n;j++)
 	{
 	 if(!(mask&(1<<j)))
	  {
	  	if(a[k][j])
	   dp[mask|(1<<j)]+=dp[mask];
	   dp[mask|(1<<j)]%=MOD;  	
	  }	
	}
 }
 cout<<dp[powe[n]-1]<<endl;
}

Measured memory_bytes: 11748
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
using namespace std;
int k;
int dp[30][10];
vector<int> gen(int x){
	vector<int> ret={};
	if(x>=1)
		ret.push_back(x-1);
	ret.push_back(x);
	if(x<=8)
		ret.push_back(x+1);
	return ret;
}
void get(int wei,int num,vector<int> vec){
	if(wei==0)
		return;
	//wei digits,#num
	for(int i:vec){
		//front:i
		num-=dp[wei][i];
		if(num<=0){
			//full
			cout<<i;
			num+=dp[wei][i];
			get(wei-1,num,gen(i));
			return;
		}
	}
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>k;
	for(int i=0;i<=9;i++)
		dp[1][i]=1;
	//dp[i][j]:i digits,front=j
	int ws=0;
	int tot=0;
	for(int i=1;i<=15;i++){
		if(i==1)
			goto pos;
		for(int j=1;j<=9;j++){
			dp[i][j]+=dp[i-1][j-1];
		}
		for(int j=0;j<=8;j++){
			dp[i][j]+=dp[i-1][j+1];
		}
		for(int j=0;j<=9;j++){
			dp[i][j]+=dp[i-1][j]; 
		}
		pos:;
		for(int j=1;j<=9;j++)
			tot+=dp[i][j];
		if(tot>=k){
			ws=i;
			for(int j=1;j<=9;j++)
				tot-=dp[i][j];
			k-=tot;
			break;
		}
	}
	//ws digits
	get(ws,k,{1,2,3,4,5,6,7,8,9});
	return 0;
}


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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題164

            int n = int.Parse(Console.ReadLine());

            HashSet<string> keihin = new HashSet<string>();

            for (int i = 0; i < n; i++)
            {
                string a = Console.ReadLine();

                keihin.Add(a);
            }


            Console.WriteLine(keihin.Count());

            //List<string> keihin = new List<string>();

            //for (int i = 0; i < n; i++)
            //{
            //    string s = Console.ReadLine();

            //    var result = keihin.Find(x => x == s);

            //    if (result == null)
            //    {
            //        keihin.Add(s);
            //    }
            //}

            ////foreach (var a in keihin)
            ////{
            ////    Console.WriteLine(a);
            ////}

            //Console.WriteLine(keihin.Count());

        }


    }
}


Measured memory_bytes: 47416
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>
#include <time.h>


int main(void){
    long N,K;
    std::cin >> N >> K;
    long A[200000+1];
    for(long i=1; i<=N; i++){
        std::cin >> A[i];
    }

    for(long i=K+1; i<=N; i++){
        if(A[i]<=A[i-K]){
            std::cout << "No" << std::endl;
        }else{
            std::cout << "Yes" << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5188
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    string s;cin>>s;
    bool y=false,m=false;
    if(s[0] <= '1' && s[0] >= '0'){
        if(s[0] == '1' && s[1] <='2'){
            y = true;
        }else if(s[0] == '0' && s[1] >= '1'){
            y = true;
        }

    }
    if(s[2] <= '1' && s[2] >= '0'){
        if(s[2] == '1' && s[3] <='2'){
            m = true;
        }else if (s[2] == '0' && s[3] >= '1'){
            m = true;
        }
    }
    if(y && m){
        cout << "AMBIGUOUS";
    }else{
        if(y){
            cout << "MMYY";
        }else if(m){
            cout << "YYMM";
        }else{
            cout << "NA";
        }
    }


}

Measured memory_bytes: 256
function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  const ary = args[1].split(' ').map(n => parseInt(n, 10));
  let ans = 999999; //ありえない数字を入れておく
  
  //区切りループ
  for (let i = 1; i < N; i++) {
    l = 0; //左グループ
    r = 0; //右グループ
    for (let j = 0; j < i; j++) l += ary[j];
    for (let j = i; j < N; j++) r += ary[j];
    gap = Math.abs(l - r);
    ans = Math.min(ans, gap);
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#include <iostream>
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define pll pair<long long, long long>
#define pli pair<long long, int>
#define pil pair<int, long long>
#define pii pair<int, int>
#define forl(i, a, n) for (lli i = a; i < n; i++)
#define rfor(i, n, a) for (int i = n; i >= a; i--)
#define fore(i, a, n) for (int i = a; i <= n; i++)
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
ll mod = 1000000007;
ll power(ll num, ll r)
{
    if (r == 0)
        return 1;
    if (r == 1)
        return num % mod;
    ll ans = power(num, r / 2) % mod;
    if (r % 2 == 0)
    {
        return (ans * ans) % mod;
    }
    return (((ans * ans) % mod) * num) % mod;
}
ll modinv(ll num)
{
    return power(num, mod - 2);
}
bool can(int n, int m, int i, int j)
{
    if (i < n && i >= 0 && j < m && j >= 0)
    {
        return true;
    }
    return false;
}
int main()
{
    fastio;
    lli a[5];
    forl(i, 1, 6)
    {
        cin >> a[i - 1];
        if (a[i - 1] == 0)
        {
            p1(i);
            break;
        }
    }
}


Measured memory_bytes: 3644
def main():
    H, W, D = map(int, input().split())
    inv = [(0, 0)] * (H*W+1)
    for i in range(H):
        s = list(map(int, input().split()))
        for j in range(W):
            inv[s[j]] = (i, j)
    cumsum = [0] * (H*W+1)
    for x in range(1, H*W+1):
        if x-D > 0:
            ci, cj = inv[x]
            pi, pj = inv[x-D]
            cumsum[x] = cumsum[x-D] + abs(ci-pi) + abs(cj-pj)
    Q = int(input())
    for _ in range(Q):
        L, R = map(int, input().split())
        print(cumsum[R] - cumsum[L])


if __name__ == "__main__":
    main()


Measured memory_bytes: 57564
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    map<char,int> m;
    m['R'] = 0; m['G']=1; m['B'] = 2;
    int n; string s;
    while(cin>>n>>s){
        ll cnt = 0;
        vi a(n);
        forn(i,n) a[i]=m[s[i]];

        vvi pre(n, vi(3));
        pre[0][a[0]] = 1;
        fore(i,1,n){
            forn(j,3)
                pre[i][j] = pre[i-1][j];
            
            pre[i][a[i]]++;
        }


        fore(l,0,n){
            fore(r,l+1,n){
                if(a[l]==a[r]) continue;
                int oth = 3 - a[l] - a[r];
                cnt+= pre[r-1][oth] - pre[l][oth];
                if( (l+r)%2==0 && a[(l+r)/2]==oth) --cnt;
            }
        }
        
        cout<<cnt<<endl;
    }

    return 0;
}

Measured memory_bytes: 3796
INF=int(1e6)

N=int(input())
heights=[int(x) for x in input().split()]
# print('heights: ',heights)
dp=[INF]*N
# print(dp)
if(N==1):
  print(dp[0])
  exit()

dp[0]=0
dp[1]=abs(heights[1]-heights[0])

for i in range(2,N):
	dp[i]= min(abs(heights[i]- heights[i-1])+ dp[i-1],abs(heights[i]- heights[i-2])+ dp[i-2])


# print('dp: ',dp)
print(dp[N-1])

#30->60->60->50
#30   30  30  40

Measured memory_bytes: 13976
#include <cstdio>
bool isLeap(int year)
{
	if (year % 400 == 0) return true;
	if (year % 100 == 0) return false;
	return (year % 4 == 0);
}
long long dateserial(int year, int month, int day)
{
	static int days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	long long res = day;
	for (int i = 0; i < month-1; ++i) {
		res += days[i];
		if (isLeap(year) && i == 1) res++;
	}
	for (int i = 1; i < year; ++i) {
		res += 365;
		if (isLeap(i)) res++;
	}
	return res;
}
int main()
{
	while (true) {
		int y1, m1, d1, y2, m2, d2;
		scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
		if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break;

		long long date1 = dateserial(y1, m1, d1);
		long long date2 = dateserial(y2, m2, d2);
		printf("%d\n", date2 - date1);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b;
    cin >> a >> b;
    int ab = a * b;
    cout << (ab % 2 ? "Odd" : "Even") << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.OptionalInt;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			br.readLine();

			OptionalInt count = Stream.of(br.readLine().split(" "))
					.mapToInt(Integer::parseInt)
					.map(Main::getCan2DivCount)
					.min();

			System.out.println(count.orElse(0));
		}
	}

	private static int getCan2DivCount(int num) {
		if (num % 2 == 0) {
			return 1 + getCan2DivCount(num / 2);
		} else {
			return 0;
		}
	}
}


Measured memory_bytes: 26708
import java.util.*;
 
class Main{
    public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		StringBuffer sb = new StringBuffer(scan.next()); //?????????
		int n = scan.nextInt(); //????????????????????°
		int cnt = 0;
		while(cnt < n+1){
			String[] cmd = scan.nextLine().split(" ");
			switch(cmd[0]){
				case "reverse":
					StringBuffer tmpSb = new StringBuffer(sb.substring(Integer.parseInt(cmd[1]), Integer.parseInt(cmd[2])+1));
					tmpSb = tmpSb.reverse();
					sb.delete(Integer.parseInt(cmd[1]), Integer.parseInt(cmd[2])+1);
					sb.insert(Integer.parseInt(cmd[1]), tmpSb);
					break;
				case "replace":
					sb.delete(Integer.parseInt(cmd[1]), Integer.parseInt(cmd[2])+1);
					sb.insert(Integer.parseInt(cmd[1]), cmd[3]);
					break;
				case "print":
					String print = sb.substring(Integer.parseInt(cmd[1]), Integer.parseInt(cmd[2])+1);
					System.out.println(print);
					break;
			}
			++cnt;
		}
    }
}

Measured memory_bytes: 28120
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int a,b;cin>>a>>b;
    cout<<a+b/2;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define mod 998244353
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define si set<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define vvii vector<vii>
#define vsi vector<si>
#define endl "\n"
#define rep(i, n) for(i = 0; i < (n); i++)
#define rrep(i, n) for(i = (n - 1); i >= 0; i--)
#define MAXN 200001
#define read(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
using namespace std;
void solve1();

int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool comp(pii a,pii b)
{
    return a.ss<b.ss;
}
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int n,x,m;int ans=0;
    cin>>n>>x>>m;
    vi vec,vec2;vec.pb(x);
    map<int,int>me;
    me[x]=1;
    int a=1;
    int c=x;
    while(c!=0)
    {
        c=(c*c)%m;
        if(me[c]==1)break;
        if(c==0)break;
        me[c]=1;
        vec.pb(c);a++;
    }
    if(c==0)
    {
        for(int i=0;i<min((int)vec.size(),n);i++)
        {
            ans+=vec[i];
        }
        cout<<ans<<endl;return;
    }
    else
    {
        int sum=0,p=0;
        for(int i=0;i<vec.size();i++)
        {
            if(vec[i]==c)
            {
                p=i;
                for(int j=i;j<vec.size();j++)
                {
                    vec2.pb(vec[j]);
                }
                break;
            }
            sum+=vec[i];
        }
        if(n<p)
        {
            for(int i=0;i<p;i++)
            {
                ans+=vec[i];
            }
        }
        else
        {
            ans+=sum;n-=p;
            sum=0;
            for(int i=0;i<vec2.size();i++)
            {
                sum+=vec2[i];
            }
            int z=vec2.size();
            ans+=sum*(n/z);
            n%=z;
            for(int i=0;i<n;i++)
            {
                ans+=vec2[i];
            }
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 7504
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,T;
    cin>>n>>T;
    int c[n],t[n];
    int ans=INF;
    for(int i=0;i<n;i++){
        cin>>c[i]>>t[i];
    }
    int cost=INF;
    for(int i=0;i<n;i++){
        if(t[i]<=T){
            cost=min(cost,c[i]);
        }
    }
    if(cost!=INF){
        cout<<cost<<endl;
    }else{
        cout<<"TLE"<<endl;
    }
 return 0;   
}

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



#define SIZE 100005

struct Edge{
	Edge(int arg_to, ll arg_mult[3]){
		to = arg_to;
		for(int i = 0; i < 3; i++){

			mult[i] = arg_mult[i];
		}
	}
	int to;
	ll mult[3];
};

int V,E;
ll MOD[3] = {1300000003,1300000021,1300000049};
ll table[SIZE][3];
bool visited[SIZE];
vector<Edge> G[SIZE];


ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

bool dfs(int node_id,ll value[3],int pre){

	visited[node_id] = true;

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

		table[node_id][i] = value[i];
	}


	for(int i = 0; i < G[node_id].size(); i++){

		int next = G[node_id][i].to;
		if(next == pre)continue;

		ll next_value[3];

		for(int k = 0; k < 3; k++){

			next_value[k] = value[k]*G[node_id][i].mult[k];
			next_value[k] %= MOD[k];
		}

		if(visited[next]){

			for(int k = 0; k < 3; k++){

				if(table[next][k] != next_value[k]){

					return false;
				}
			}

		}else{ //未訪問の場合

			if(!dfs(next,next_value,node_id)){
				return false;
			}
		}
	}

	return true;
}

int main(){

	scanf("%d %d",&V,&E);

	int from,to;
	ll num,mult[3],inv_mult[3];

	for(int loop = 0; loop < E; loop++){

		scanf("%d %d %lld",&from,&to,&num);
		from--;
		to--;

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

			mult[i] = num;
		}

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

			inv_mult[i] = mod_inverse(num,MOD[i]);
		}

		G[from].push_back(Edge(to,mult));
		G[to].push_back(Edge(from,inv_mult));
	}

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

		visited[i] = false;
		for(int k = 0; k < 3; k++){

			table[i][k] = -1;
		}
	}

	for(int i = 0; i < V; i++){
		if(visited[i])continue;

		ll value[3] = {1,1,1};

		if(!dfs(i,value,-1)){

			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}



Measured memory_bytes: 24336
import sys

n = int(input())
w = [list(map(int, input().split())) for _ in range(n)]
w = sorted(w, key=lambda x: x[1])

time = 0
for i in range(n):
    time += w[i][0]
    if time > w[i][1]:
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 55264
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,sum,i,b,h,minn=1000000000,a[200000];
	cin>>n>>h;
	sum=0;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		
	}
	sort(a,a+n+1);
	for(i=1;i<=n-h+1;i++)
	{
		minn=min(minn,a[i+h-1]-a[i]);
	}
	cout<<minn<<endl;
	return 0;
 } 

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

int main() {
    int y,m,d;
    char c1,c2;
    cin >> y >> c1 >> m >> c2 >> d;
    if(m <= 4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl; 
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if((s[2]==s[3])&&(s[4]==s[5])) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
vector<int> G[N];
int a[N], ans[N];
void dfs(int u, int fa, vector<int>& t) {
    ans[u] = t.size();
    for(auto v : G[u]) {
        if(v == fa) continue;
        int L = 0, R = t.size() - 1, x = -1;
        while(L <= R) {
            int mid = (L + R) >> 1;
            if(t[mid] >= a[v]) x = mid, R = mid - 1;
            else L = mid + 1;
        }
        int tmp;
        if(x == -1) t.push_back(a[v]);
        else tmp = t[x], t[x] = a[v];
        dfs(v, u, t);
        if(x == -1) t.pop_back();
        else t[x] = tmp;
    }
}
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for(int i = 1, u, v; i < n; i++) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<int> t;
    t.push_back(a[1]);
    dfs(1, -1, t);
    for(int i = 1; i <= n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

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

int main() {
    ll N;
    cin >> N;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> Ones(61, 0);

    auto modpow = [](ll a, ll n, ll mod) {
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    };

    rep(i, N) {
        rep(b, 61) {
            if (bitset<61>(A[i])[b] == 1) {
                Ones[b]++;
            }
        }
    }

    ll ans = 0;
    rep(i, 61) {
        ll p = (ll)modpow(2, i, 1e9 + 7);
        ans += (Ones[i] * (N - Ones[i])) % ((ll)1e9 + 7) * p;
        ans %= ((ll)1e9 + 7);
    }
    cout << (ll)ans << endl;
}

Measured memory_bytes: 2560
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define N 200010
int a[N],p[N],n;
long long ans=0,mx=0;
int main()
{
	n=read();
	for (int i=1;i<=n;i++) a[i]=read(),p[a[i]]=i;
	for (int i=1;i<=n;i++)
	{
		if (p[i]>p[i-1]) ans++;else ans=1;
		mx=max(mx,ans);
	}
	cout<<n-mx;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 15 == 0) continue;
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
	long long int a,b,x;
	scanf("%lld %lld %lld",&a,&b,&x);
	if(a%x==0) printf("%lld",b/x-a/x+1);
	else printf("%lld",b/x-a/x);
	return 0;
}

Measured memory_bytes: 1728
(defvar *ans*)

(defun solve (x1 y1 x2 y2)
  (let (x3 y3 x4 y4)
    (setq x3 (- x2 (- y2 y1)))
    (setq y3 (+ y2 (- x2 x1)))
    (setq x4 (- x1 (- y2 y1)))
    (setq y4 (+ y1 (- x2 x1)))
    (list x3 y3 x4 y4)))

(defun main ()
  (let ((x1 (read))
        (y1 (read))
        (x2 (read))
        (y2 (read)))
    (setf *ans* (solve x1 y1 x2 y2))
    (fresh-line)
    (dotimes (i 4)
      (princ (nth i *ans*))
      (princ #\space))
    (princ #\newline)
    (fresh-line)))

(main)


Measured memory_bytes: 24360
#include<stdio.h>

typedef struct{
  int n;
  char c;
  int status;
} Card;

#define N 100001

int partition(Card *,int,int);
void Quicksort(Card *,int,int);
int isStable(Card *,int);
void swap(Card *,Card *);

int main(int argc, char const *argv[]) {
 
  int i;
  int num;
  int p = 0;
  Card A[100001];
 
  scanf("%d",&num);
 
  for( i = 0 ; i < num ; i++ ){
    scanf(" %c %d",&A[i].c,&A[i].n);
    A[i].status = i;
  }
 
  Quicksort(A,p,num-1);
 
  if( isStable(A,num) ){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
 
 
 
  for( i = 0 ; i < num ; i++ ){
    printf("%c %d\n",A[i].c,A[i].n);
  }
 
  return 0;
}

void Quicksort(Card *A, int p, int r){
 
  int q;
 
  if( p < r ){
      q = partition(A,p,r);
      Quicksort(A,p,q-1);
      Quicksort(A,q+1,r);
  }
 
}

int partition(Card *A, int p, int r){
 
  int x;
  int i,j;
 
  x = A[r].n;
  i = p-1;
 
  for( j = p ; j < r ; j++ ){
    if( A[j].n <= x ){
      i++;
      swap(&A[i],&A[j]);
    }
  }
 
  swap(&A[i+1],&A[r]);
 
  return i+1;
 
}


int isStable(Card *A,int n){
  int i;
  for( i = 1 ; i < n ; i++ ){
    if( A[i-1].n == A[i].n ){
      if( A[i-1].status > A[i].status ){
        return 0;
      }
    }
  }
  return 1;
}
 
void swap(Card *x, Card *y){
 
  Card temp;
 
  temp = *x;
  *x = *y;
  *y = temp;
 
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100010
int a[N],n;
int lowbit(int x)
{
    return x&(-x);
}
void add(int x)
{
    while(x<=n)
    {
        a[x]++;
        x=x+lowbit(x);
    }
}
void del(int x)
{
    while(x<=n)
    {
        a[x]--;
        x=x+lowbit(x);
    }
}
LL query(int x)
{
    LL ans=0;
    while(x)
    {
        ans=ans+a[x];
        x=x-lowbit(x);
    }
    return ans;
}
int main()
{
    int i,j,m,l,r,ans;
    LL s;
    scanf("%d%d",&n,&m);
    memset(a,0,sizeof(a));
    add(1);
    for(i=1;i<=m;i++)
    {
        scanf("%d%d",&l,&r);
        if(l>1)
        {
            del(1);
            add(l);
        }
        del(r+1);
    }
    ans=0;
    for(i=1;i<=n;i++)
    {
        s=query(i);
        if(s>0)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
n,m = map(int,input().split())
p = []
S = []
p_count = 0
a_count = 0
for i in range(m):
    temp1,temp2 = input().split()
    p.append(int(temp1))
    S.append(temp2)
n_table = [0 for i in range(n)]
n_wa_table = [0 for i in range(n)]
for p,s in zip(p,S):
    if s == "AC":
        n_table[p-1] = 1
    if s == "WA" and n_table[p-1] == 0:
        n_wa_table[p-1] += 1
a_count = n_table.count(1)
wai = [i for i, x in enumerate(n_table) if x == 1]
for i in wai:
    p_count += n_wa_table[i]
print(a_count,p_count)

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

using namespace std;

int main()
{
    int H, W;
    string line, p;

    while (cin >> H >> W)
    {
        if (H == 0 && W == 0)
        {
            break;
        }

        for (int y = 0; y < H; y++)
        {
            line = "";
            p = "";

            for (int x = 0; x < W; x++)
            {
                if (x == 0 || x == W - 1)
                {
                    p = "#";
                }
                else
                {
                    if (y == 0 || y == H - 1)
                    {
                        p = "#";
                    }
                    else
                    {
                        p = ".";
                    }
                }

                line += p;
            }

            cout << line << "\n";
        }
        
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 3212
/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
#define FOR(i, st, en, ch) for(register int i = (st); i <= (en) ; i += (ch))
#define RFOR(i, st, en, ch) for(register int i = (st); i >= (en) ; i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
/*********************************************************************/

void test(int r)
{
	int n,k;
	cin>>n>>k;
	vector<int>v(n+1,0);
	int i,j;
	for(i=1;i<=k;i++)
	{
		int d;
		cin>>d;
		for(j=1;j<=d;j++)
		{
			int x;
			cin>>x;
			v[x]++;
		}
	}
	int ans=0;
	for(i=1;i<=n;i++)
	{
		if(!v[i])
			ans++;
	}
	cout<<ans;
	
}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin>>n>>m;
	int ac=0,wa=0;
	int p;
	string a;
	int list[100001][2]={};
	while(m)
	{
		cin>>p>>a;
		if(a=="AC"&&list[p][0]==0)
		{
			list[p][0]=1;
			ac++;
			wa+=list[p][1];
		}
		else
		{
			list[p][1]++;
		}
		m--;
	}
	cout<<ac<<" "<<wa;
	return 0;
}

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

int main(void){
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i%2==0){
            cout<<s[i];
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
typedef long long ll;

int a, b;

int main()
{
	ios::sync_with_stdio(false);
    cin >> a >> b;
    bool flag = 0;
    for (int i = 0; i <= a; i++)
    	if (i * 2 + (a - i) * 4 == b) flag = 1;
	if (flag) cout << "Yes" << endl;
	else cout << "No\n";
	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<queue<int>> tbl(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n - 1; ++j) {
      int a;
      cin >> a;
      tbl[i].push(a - 1);
    }
  }

  int ans = -1;
  vector<int> cnt(n, 0);
  while (true) {
    bool all_skip = true, ok = false;
    for (int i = 0; i < n; ++i) {
      if (tbl[i].empty()) {
        continue;
      }

      all_skip = false;

      int opponent = tbl[i].front();
      if (i == tbl[opponent].front()) {
        ok = true;
        tbl[opponent].pop();
        tbl[i].pop();
        cnt[i] = cnt[opponent] = max(cnt[i], cnt[opponent]) + 1;
      }
    }

    if (all_skip) {
      ans = *max_element(cnt.begin(), cnt.end());
      break;
    }

    if (!ok) {
      break;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  int N;
  cin >> N;
  vint H(N);
  vint sub(N-1);
  cin >> H;
  
  for(int i=1; i<N; i++){
    sub[i-1] = H[i]-H[i-1];
  }
  
  
  int ans = 0;
  int cnt = 0;
  for(auto s:sub){
    if(s <= 0){
      cnt++;
    }
    else{
      cnt = 0;
    }
    ans = max(ans,cnt);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {
	long long n,y;
	cin >> n >> y;
	for(int a=0;a<=n;a++){
		for(int b=0;b<=n;b++){
			long long temp=y-10000*a-5000*b;
			int c=temp/1000;
			if(temp>=0 && temp%1000==0 && n==a+b+c){
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}
	}
	cout << "-1" << " " << "-1" << " " << "-1" << endl;
	return 0;
}


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

using namespace std;

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> p;
    for(int i=0; i < N; i++){
        p.push_back(0);
    }

    vector<int> A;
    for(int i=0; i<Q; i++){
        int t;
        cin >> t;
        A.push_back(t);
    }

    for(auto it = A.begin(); it != A.end(); ++it){
        p[*it-1] += 1;
    }

    for(auto it = p.begin(); it != p.end(); ++it){
        if(Q - *it >= K) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
#define pb push_back
using pii = pair<int, pair<int,int>>;
#define fi first
#define se second
long long n;
int main() {
    while (cin >> n) {
        cout << (int)sqrt(n) * (int)sqrt(n) << endl;

    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

long long cost[100002];
const long long INF=1LL<<60;
int h[100002];
int N;
void dfs(int i){
if(i==N)return;
cost[i+1]=min(cost[i+1],cost[i]+abs(h[i+1]-h[i]));

cost[i+2]=min(cost[i+2],cost[i]+abs(h[i+2]-h[i]));

dfs(i+1);
return;
}


int main() {
   cin >> N ;


rep(i,N){
cin >> h[i];
cost[i]=INF;
}

cost[0]=0;

// sort(array.begin(),array.end(),greater<long double>());

dfs(0);

cout << cost[N-1];

return 0;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int r; cin >> r;
    cout << r*r << endl;
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int left,right;
  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      left=i;
      break;
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='Z'){
      right=i;
      break;
    }
  }
  cout<<right-left+1<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  int a,b,s;

  scanf("%d %d", &a,&b);
  s=a*b;
  a=2*a;
  b=2*b;
  a=a+b;
  printf("%d %d\n", s,a);
  return 0;
}

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

int main(){
    long long int n,k,a=0,b=0;
    cin>>n>>k;
    a=n%k;
    b=abs(k-a);
    cout<<min(a,b)<<endl;
    
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

const int Maxn = 100005;

int n;
char str[Maxn];
int nxt = 1;

int Create(int v)
{
    int my = nxt++;
    v--;
    while (v != 0)
        if (str[v] == '1') {
            printf("%d %d\n", my, Create(v));
            v = 0;
        } else {
            printf("%d %d\n", my, nxt++);
            v--;
        }
    return my;
}

int main()
{
    scanf("%s", str + 1);
    n = strlen(str + 1);
    if (str[n] == '1' || str[1] == '0') { printf("-1\n"); return 0; }
    for (int i = 1; i < n; i++)
        if (str[i] != str[n - i]) { printf("-1\n"); return 0; }
    str[n] = '1';
    Create(n);
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int64_t> lucas(N + 1);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for(int i = 2; i <= N; i++) {
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  }
  cout << lucas.at(N) << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
    //データ定義
    string w;
    string t;
    int i;
    int totalWord = 0;
    
    //検索データ入力
    cin >> w;
    
    // //小文字に落とす
    // for(i =0; i < w.size(); i++){
    //     if('A'<= w[i] && w[i] <= 'Z'){
    //         w[i] += 'a' - 'A';
    //     }
    // }
    
    //テキスト入力
    cin >> t;
    while(t != "END_OF_TEXT"){
        for( i = 0; i < t.size(); i++ ){
            //小文字に落とす
            if('A'<= t[i] && t[i] <= 'Z'){
                t[i] += 'a' - 'A';
            }
        }
        if(w == t){
            totalWord++;
        }
        //次のテキストを入力
        cin >> t;
    }
    
    //結果出力
    cout << totalWord << endl;
}


Measured memory_bytes: 3228
import re

i = input()

j = re.sub(r' .*', '', str(i))
k = re.sub(r'\d*\s', '', str(i))

def Even_number(a, b):
    if a*b % 2 == 0:
        print('Even')
    else:
        print('Odd')

Even_number(int(j), int(k))


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/






int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int val; cin >> val;
  cout << 1-val << endl;





/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    string a, b;
    cin >> a >> b;
    if ( a.length() > b.length() ) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if ( a.length() < b.length() ) {
        cout << "LESS" << endl;
        return 0;
    }
    else {
        int idx = 0;
        while(1) {
            if ( idx == a.length() ) break;
            if ( a[idx] - '0' > b[idx] - '0' ) {
                cout << "GREATER" << endl;
                return 0;
            }
            if ( a[idx] - '0' < b[idx] - '0' ) {
                cout << "LESS" << endl;
                return 0;
            }
            ++idx;
        }
        cout << "EQUAL" << endl;
        return 0;
    }
}


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

typedef struct ana{
    char nam[11];
}ana;

int compare_char(const void *a,const void *b){
    return *(char*)a - *(char*)b;
}

int compare_char2(const void *a,const void *b){
    return strcmp(((ana*)a)->nam,((ana*)b)->nam);
}

int main(){
    char h[11];
    int n,x=1;
    long d=0;
    scanf("%d",&n);
    ana s[n];
    for(int k=0;k<n;k++){
        scanf("%s",h);
        qsort(h,10,sizeof(char),compare_char);
        strcpy(s[k].nam,h);
    }
    qsort(s,n,sizeof(ana),compare_char2);
    for(int i=1;i<n;i++){
        if(strcmp(s[i-1].nam,s[i].nam)==0){
            d+=x;
            x++;
        }
        else{
            x=1;
        }
    }
    printf("%ld\n",d);
    return 0;
}


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

typedef long long lint;
const int maxn = 100005;

int n, m;
int fa[maxn], pu, pv;

int f[maxn], siz[maxn], dep[maxn], col[maxn], cnt, p[maxn];
lint ans;

struct edge
{
	int to, next;
} e[maxn * 2];
int h[maxn], tot;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline int find(int x)
{
	if (!fa[x]) return x;
	return fa[x] = find(fa[x]);
}

inline void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]}; h[u] = tot;
	e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}

void dfs(int u, int fa, int t)
{
	siz[u] += t == 0 ? 1 : -1; col[u] = t;
	dep[u] = dep[fa] + 1;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa) {
			f[v] = u, dfs(v, u, t ^ 1);
			siz[u] += siz[v];
		}
	ans += abs(siz[u]);
}

namespace case1
{
	
	void solve()
	{
		if (siz[1] == 0) printf("%lld\n", ans);
		else puts("-1");
	}

}

namespace case2
{
	
	void solve()
	{
		if (siz[1] & 1) return puts("-1"), void();
		int cnt = siz[1] >> 1;
		memset(siz + 1, 0, sizeof(int) * n);
		ans = abs(cnt); siz[pu] -= cnt; siz[pv] -= cnt;
		dfs(1, 0, 0);
		printf("%lld\n", ans);
	}
	
}

namespace case3
{

    void solve()
	{
		if (siz[1]) return puts("-1"), void();
		ans = 0;
		while (pu != pv) {
			if (dep[pu] > dep[pv]) p[++cnt] = siz[pu], siz[pu] = 0, pu = f[pu];
			else p[++cnt] = -siz[pv], siz[pv] = 0, pv = f[pv];
		}
		p[++cnt] = 0;
		sort(p + 1, p + cnt + 1);
		for (int i = 1; i <= cnt; ++i)
			ans += abs(p[(cnt + 1) >> 1] - p[i]);
		for (int i = 1; i <= n; ++i) ans += abs(siz[i]);
		printf("%lld\n", ans);
	}
	
}

int main()
{
	n = gi(); m = gi();
	for (int u, v, i = 1; i <= m; ++i) {
		u = gi(); v = gi();
		if (find(u) != find(v)) add(u, v), fa[find(u)] = v;
		else pu = u, pv = v;
	}
	
	dfs(1, 0, 0);
	
	if (m == n - 1) case1::solve();
	else if (col[pu] == col[pv]) case2::solve();
	else case3::solve();
	
	return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  for(int i=0;i<=a.size()/4;i++){
    if(a.at(i)!=a.at(a.size()/2-i-1) || a.at(a.size()/2+i+1)!=a.at(a.size()-i-1) || a.at(i)!=a.at(a.size()-i-1)){
    cout << "No" << endl;
    return 0;
    }
  }  
  cout << "Yes" << endl;  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,num=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
		if(i*500+j*100+k*50==x) num++;
	cout<<num<<endl;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    vi A(N);
    REP(i, 0, N) cin >> A[i];
    int count = 0;
    REP(i, 0, N){
        if(i % 2 == 0 && A[i]%2 == 1) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3624