akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int h,w,ax,ay,bx,by;
vector<int> G[500*500+1];
int px[]={0,1,0,-1};
int py[]={1,0,-1,0};
long long int mod=1e9+7;
int comb(int x,int y){
  int ans=x+y*w;
  return ans;
}

typedef pair<int, int> P;
vector<pair<int,long long int> > dist(500*500+1,make_pair(1e9,0));

void dijkstra(long long int s){
  priority_queue<P,vector<P>,greater<P> > que;
  dist[s]=make_pair(0,1);
  que.push(P(0,s));
  while(!que.empty()){
    P p=que.top();
    que.pop();
    long long int v=p.second;
    long long int d=p.first;
    if(dist[v].first<d)continue;
    for(int i=0;i<G[v].size();i++){
      long long int d2=d+1;
      if(dist[G[v][i]].first>d2){
        dist[G[v][i]].first=d2;
        dist[G[v][i]].second=dist[v].second;
        dist[G[v][i]].second%mod;
        que.push(P(dist[G[v][i]].first,G[v][i]));
      }else if(dist[G[v][i]].first==d2){
        dist[G[v][i]].second+=dist[v].second;
        dist[G[v][i]].second%=mod;
      }
    }
  }
}

int main(){
  cin>>h>>w>>ay>>ax>>by>>bx;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<4;k++){
        int nx=j+px[k];
        int ny=i+py[k];
        if(nx>=0&&ny>=0&&nx<w&&ny<h){
          G[comb(j,i)].push_back(comb(nx,ny));
        }
      }
      int nx=0;
      int ny=i;
      if(nx>=0&&ny>=0&&nx<w&&ny<h){
        G[comb(j,i)].push_back(comb(nx,ny));
      }
      nx=w-1;
      ny=i;
      if(nx>=0&&ny>=0&&nx<w&&ny<h){
        G[comb(j,i)].push_back(comb(nx,ny));
      }
      nx=j;
      ny=0;
      if(nx>=0&&ny>=0&&nx<w&&ny<h){
        G[comb(j,i)].push_back(comb(nx,ny));
      }
      nx=j;
      ny=h-1;
      if(nx>=0&&ny>=0&&nx<w&&ny<h){
        G[comb(j,i)].push_back(comb(nx,ny));
      }
    }
  }
  dijkstra(comb(ax,ay));
  //for(int i=0;i<h*w;i++)cout<<dist[i].first<<" "<<dist[i].second<<endl;
  cout<<dist[comb(bx,by)].first<<" "<<dist[comb(bx,by)].second%mod<<endl;
}



Measured memory_bytes: 21312
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
d = [0] * (n + 1)
j = 0
for i in range(n):
    while j < n and b[i] <= a[j]: j += 1
    d[i] = (n - j)
for i in range(n - 1, 0, -1):
    d[i - 1] += d[i]
j = 0
s = 0
for i in range(n):
    while j < n and c[i] <= b[j]: j += 1
    s += d[j]
print(s)


Measured memory_bytes: 23644
import java.io.*;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		String watchStr = input.readLine();
		
		int watch = Integer.parseInt(watchStr);
		
		int hour = 3600;
		
		int minute = 60;
		
		System.out.println(watch / hour + ":" + (watch % hour) / minute + ":" + ((watch % hour) % minute));
	}
}



Measured memory_bytes: 24356
#include "bits/stdc++.h"
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0){
    cout<<1<<endl;
    return 0;
  }
  if(b==0){
    cout<<2<<endl;
    return 0;
  }
  if(c==0){
    cout<<3<<endl;
    return 0;
  }
  if(d==0){
    cout<<4<<endl;
    return 0;
  }
  if(e==0){
    cout<<5<<endl;
    return 0;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef  pair<int,int> P;


int n;

int main()
{
int cnt=0;
cin>>n;
for(int i=1;i<=n-1;i++)
{
for(int j=1;j*j<i;j++)
{
    if(i%j==0)cnt+=2;

}
int t=floor(sqrt(i));
if(t*t==i)cnt++;
}
cout <<cnt;
}


Measured memory_bytes: 3676
n , m = map(int,input().split())

grid = []
for i in range(n):
  temp = list(input())
  grid.append(temp)


dp = [[0 for _ in range(m)] for i in range(n)]

dp[0][0]=1
mod = 10**9 + 7
for i in range(n):
  for j in range(m):
    if grid[i][j]=='#':
      continue
    if i>0:
      dp[i][j] +=dp[i-1][j]%mod
    if j>0:
      dp[i][j] +=dp[i][j-1]%mod
      
print(dp[n-1][m-1]%mod)

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

const int maxn = 1e5 + 10;
int n, l, r, q[maxn], vis[maxn];

vector <int> e[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d %d", &u, &v);
		e[u].push_back(v), e[v].push_back(u);
	}
	l = 1, r = 0;
	vis[1] = 1;
	vis[n] = 2;
	q[++r] = 1;
	q[++r] = n;
	for (; l <= r; ) {
		int u = q[l++];
		for (int v : e[u]) {
			if (!vis[v]) {
				vis[v] = vis[u];
				q[++r] = v;
			}
		}
	}
	int sum1 = 0, sum2 = 0;
	for (int i = 1; i <= n; i++) {
		if (vis[i] == 1) {
			sum1++;
		} else {
			sum2++;
		}
	}
	puts(sum1 > sum2 ? "Fennec" : "Snuke");
	return 0;
}

Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        static int Comp(Tuple<long, long> t1, Tuple<long, long> t2)
        {
            if (t1.Item2 != t2.Item2)
            {
                return t1.Item2 > t2.Item2 ? 1 : -1;
            }
            else
            {
                return t1.Item1 > t2.Item1 ? 1 : -1;
            }
        }

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            List<Tuple<long, long>> t = new List<Tuple<long, long>>();
            for(var i = 0; i < N; i++)
            {
                var p = cin.SplitReadL();
                t.Add(new Tuple<long, long>(p[0], p[1]));
            }


            t.Sort((x, y) => ((int)x.Item2 - (int)y.Item2));

            bool ok = true;
            long now = 0;

            for(var i = 0; i < N; i++)
            {
                now += t[i].Item1;
                if (now > t[i].Item2)
                {
                    ok = false;
                    break;
                }
            }
            /*foreach(var x in t)
            {
                Console.WriteLine(x);
            }*/

            Console.WriteLine(ok ? "Yes" : "No");

            //Console.Out.Flush();
        }
        
        
    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long Modulo(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }
    }

    

}


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

int main(){
    int n;
    while(cin >> n, n != 0){
        int v[n];
        int cnt = 0;
        for(int i=0; i<n; ++i){
            cin >> v[i];
        }
        while(1){
            int tmp[n];
            bool flug = true;
            for(int i=0; i<n; ++i){
                tmp[i] = 0;
                for(int j=0; j<n; ++j)
                    if(v[i] == v[j]) ++tmp[i];
                if(v[i] != tmp[i]) flug = false;
            }
            if(flug) break;
            cnt++;
            for(int i=0; i<n; ++i)
                v[i] = tmp[i];
        }
        cout << cnt << endl;
        for(int i=0; i<n; ++i)
            cout << ((i!=0)?" ":"") << v[i];
        cout << endl;
    }
    return 0;
}

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

int howmany(int);

int main() {
	int month, day, mod;
	

	while (cin >> month >> day) {
		if (month == 0) break;
		int total = 0;

		for (int i = 1;i < month; i++) {
			total += howmany(i);
		}
		total += day;
		mod = total % 7;

		switch (mod) {
		case 0:
			cout << "Wednesday" << endl;
			break;
		case 1:
			cout << "Thursday" << endl;
			break;
		case 2:
			cout << "Friday" << endl;
			break;
		case 3:
			cout << "Saturday" << endl;
			break;
		case 4:
			cout << "Sunday" << endl;
			break;
		case 5:
			cout << "Monday" << endl;
			break;
		case 6:
			cout << "Tuesday" << endl;
			break;
		default:
			break;
		}
	}

	return 0;
}

int howmany(int month) {
	if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
		return 31;
	}
	else if (month == 2) {
		return 29;
	}
	else {
		return 30;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int A, B, T;
	cin >> A >> B >> T;
	cout << B * (T / A) << endl;

	return 0;
}

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

int  main(){

	long long  n,m;
	cin >> n >> m;

	vector< long long  > dp( n+2  , 0 );

	long long  t;
	for(long long  i=0;i<m;i++){
		cin >> t;
		dp[t]=-1;
	}
	dp[n]+=1;
	for(long long  i=n-1;i>=0;i--){
		if(dp[i]!=-1){
			if( dp[i+1]!=-1 ){
				dp[i] += dp[i+1];
			}
			if(dp[i+2]!=-1){
				dp[i] += dp[i+2];
			}
			dp[i]=dp[i]%1000000007;
		}
	}

	cout << dp[0] << "\n";


	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n,k,s;cin>>n>>k>>s;
  vector<int> ans(n,s);
  for(int i=k;i<n;i++){
    ans[i]++;
    if(s>1000000)ans[i]=1;
  }
  rep(i,n){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2048
/* ****Tciitb**** */
                     
#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll ,ll >
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a-1;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;
#define N 100005 

 


 int main()
{
  io
  ll n;
  cin>>n;
  std::vector<ll> a(n);
  ll ans=0;
  rep(i,0,n)
  {
     cin>>a[i];
     ll j=1;
     while(1)
    {
      ll z=pow(2,j);
      if(a[i]%z==0)
      {
        ans++;
        j++;
      }
      else
      {
        break;

      }

    }


  }
  cout<<ans;


  
}
  

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvl = vector<vl>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"
const ll INF = 1e9+1;
const int MAX_V = 100*1000+1;

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

  vi w(N), v(N);
  REP(i, N) {
    cin >> w[i] >> v[i];
  }
  vvl dp(N+1, vl(MAX_V, INF)); // dp[i][j] = i番目までで価値がjになるように選んだときの重さの最小値
  dp[0][0] = 0;
  REP(i, N) {
    REP(j, MAX_V) {
      if (j - v[i] >= 0)
        dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
      else
        dp[i+1][j] = dp[i][j];
    }
  }
  ll ans = 0;
  REP(j, MAX_V) {
    if (dp[N][j] <= W) {
      ans = j;
    }
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 80256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    d = defaultdict(int)
    ans = 1
    d[-1] = 3
    for a in A:
        ans *= (d[a - 1] - d[a])
        ans %= 1000000007
        d[a] += 1
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 22436
#include <iostream>
using namespace std;
int main() {
  char in;
  cin >> in;
  if (in == 'A') {
    cout << 'T' << endl;
  } else if (in == 'C') {
    cout << 'G' << endl;
  } else if (in == 'G') {
    cout << 'C' << endl;
  } else if (in == 'T') {    
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

using namespace std;
 
int main(void)
{   
    int a,b,x;
    cin >> a >>b >> x;

    if(a <= x && a+b >= x)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.Array.IO
import Data.List
import Data.Int
import Control.Monad

type Arr = IOUArray (Int, Int) Int
type PointC = (Int, Int, Char)
type Point = (Int, Int)

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  t <- map (compression k) <$> getInt2DListBC
  cum <- newArray ((0, 0), (2*k, 2*k)) 0 :: IO Arr
  ans <- newArray ((0, 0), (2*k, k)) 0 :: IO Arr
  let  pos = [(i, j) | i <- [1..k], j <- [1..k]] ++ [(i, j) | i <- [k+1..2*k], j <- [1..k]]
  foldM (count k) cum t
  accum2D k cum (1, 1)
  foldM (solve k cum) ans pos
  x <- maximum <$> getElems ans
  print x

solve :: Int -> Arr -> Arr -> Point -> IO Arr
solve k cum ans (i, j)
  | i+k <= 2*k && j+k <= 2*k = do
    a <- query cum (i, j, i+k, j+k)
    b <- query cum (0, j+k, i, 2*k)
    c <- query cum (i+k, 0, 2*k, j)
    d <- query cum (i+k, j+k, 2*k, 2*k)
    e <- query cum (0, 0, i, j)
    writeArray ans (i, j) $ a + b + c + d + e
    return ans
  | otherwise = do
    a <- query cum (i, j, 2*k, j+k)
    b <- query cum (i-k, j+k, i, 2*k)
    c <- query cum (0, j, i-k, j+k)
    d <- query cum (i-k, 0, i, j)
    writeArray ans (i, j) $ a + b + c + d
    return ans

query :: Arr -> (Int, Int, Int, Int) -> IO Int
query cum (i, j, k, l) = do
  a <- readArray cum (i, j)
  b <- readArray cum (i, l)
  c <- readArray cum (k, j)
  d <- readArray cum (k, l)
  return $ a + d - b - c

next :: Int -> Point -> Point
next k (x, y)
  | y == 2*k = (x+1, 1)
  | otherwise = (x, y+1)

accum2D :: Int -> Arr -> Point -> IO ()
accum2D k cum (i, j)
  | i == 2*k+1 = return ()
  | otherwise = do
    x <- readArray cum (i-1, j)
    y <- readArray cum (i, j-1)
    z <- readArray cum (i-1, j-1)
    w <- readArray cum (i, j)
    writeArray cum (i, j) $ x + y - z + w
    accum2D k cum $ next k (i, j)

compression :: Int -> PointC -> Point
compression k (x, y, 'B') = (mod x $ 2*k, mod y $ 2*k)
compression k (x, y, 'W') = (mod x $ 2*k, mod (y+k) $ 2*k)

count :: Int -> Arr -> Point -> IO Arr
count k arr (x,y) = do
  inc arr (x+1, y+1)
  return arr

inc :: Arr -> (Int, Int) -> IO ()
inc arr p = do
  x <- readArray arr p
  writeArray arr p $ x + 1

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [PointC]
getInt2DListBC = map ((\[x,y,z] -> (bsToInt x, bsToInt y, head $ BC.unpack z)) . BC.words) . BC.lines <$> BC.getContents


Measured memory_bytes: 131068
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  string n;
  cin >> n;
  int judge = 0;
  
  rep1(i, n.size()){
    judge += n[i]-'0';
  }
  if(judge % 9 == 0){
    cout << "Yes";
  } 
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3752
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		System.out.println("" + 2018 + sc.next().substring(4));
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int A = 0;
    int B = 0;
    int ans = 0;
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d %d", &A, &B);
    
    /* 入力を受け付ける部分終わり*/
    
    
    /* 何か処理*/
    ans = (A - 1) * (B - 1);
    
    if(1 == 0){
      /* 真の場合の処理 */
      
    }else{
      /* 偽の場合の処理 */
      
    }
    
    for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    }
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
    printf("%d", ans); // %dの部分にansの値が表示される
    
    /* 出力する部分*/
    
    
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a,b,c,d,e,f;
  int tempa,tempb;
  int i,j;
  char cc;
  scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
  scanf("%c",&cc);
  while(1){
    scanf("%c",&cc);
    if(cc=='\n')break;
    if(cc=='S'){
      tempa=a;
      a=e;
      e=f;
      f=b;
      b=tempa;
    }
    else if(cc=='N'){
      tempa=a;
      a=b;
      b=f;
      f=e;
      e=tempa;
    }
    else if(cc=='W'){
      tempa=a;
      a=c;
      c=f;
      f=d;
      d=tempa;
    }
    else if(cc=='E'){
      tempa=a;
      a=d;
      d=f;
      f=c;
      c=tempa;
    }
  }
  printf("%d\n",a);
  return(0);
}



Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const ll inf = 1e18+9;
int a[maxn];
int road[maxn];
int vis[maxn];

int main(){
	memset(vis,0,sizeof(vis));
	int n;
	ll k;
	scanf("%d %lld",&n,&k);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
	}
	int cnt = 1;
	int t = 1;
	vis[1] = 1;
	road[cnt++] = 1;
	int en = 0;
	while(1){
		int x = a[t];
		if(vis[x]){
			en = x;
			break;
		}else{
			vis[x] = 1;
			road[cnt++] = x;
			t = x;
		}
	}

	ll y = 0;
	for(ll i = 1;i < cnt;i++){
		if(road[i] == en){
			y = i;
			break;
		}
	}
	ll s = cnt - y;
	if(k <= y){
		printf("%d",a[road[k]]);
	}
	else{
		k -= y;
		k %= s;
		printf("%d",a[road[y+k]]);
	}
	return 0;
}

Measured memory_bytes: 5996
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int ans = 0;
        char[] tmp;
        for (int i = a; i <= b; i++)
        {
            tmp = i.ToString().ToCharArray();
            if (tmp[0] == tmp[4] && tmp[1] == tmp[3])
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 15184
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

  bool allSame = true;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      allSame = false;
      break;
    }
  }

  if (allSame) {
    cout << 0 << endl; // no moves
    return 0;
  }

  ll ans = 0;
  ll minLargeCount = 1000000007;
  for (int i = 0; i < n; i++) {
    ans += a[i];
    if (a[i] > b[i] && b[i] < minLargeCount) {
      minLargeCount = b[i];
    }
  }
  ans -= minLargeCount;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 1e5 + 2;
const ll mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;

void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}

int dp[110][M], pr[110][M], n, k, a[110];

int add(int a, int b) {
	return (a + b + ((a + b) < 0 ? mod : 0)) % mod;
}

int main() {
	data();
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	dp[0][0] = 1;
	for (int i = 0; i <= k; ++i)
		pr[0][i] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= k; ++j)
			if (j > a[i])
				dp[i][j] = add(pr[i - 1][j], -pr[i - 1][j - a[i] - 1]);	
			else
				dp[i][j] = pr[i - 1][j];
				
		for (int j = 0; j <= k; ++j)
			pr[i][j] = add(pr[i][j - 1 + (j == 0)], dp[i][j]);
	}
	printf("%d", dp[n][k]);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/

Measured memory_bytes: 84224
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const n : number = +input[0];
const a : number[] = input[1].split(' ').map((x: string): number => +x);

a.sort(compareFunc);
let ans: string = 'YES';
for (let i = 0; i < n-1; i++){
    if (a[i] === a[i+1]){
        ans = 'NO';
    }
}

console.log(ans);

Measured memory_bytes: 34472
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rep1(i,n) for (int i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
string assembleId(int k, int seq){
  string id = to_string(k);
  while(id.size()<6){
    string z = "0";
    id =z.append(id,0,id.size());
  }
  string matsu = to_string(seq);
  while(matsu.size()<6){
    string z = "0";
    matsu =z.append(matsu,0,matsu.size());
  }
  return id.append(matsu,0,matsu.size());
}
int main(){
  int n,m; cin >> n >> m;
  vector<priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>> v(n+1);
  rep(i,m){
    int p,y;
    cin >> p >> y;
    pair<int,int> u = make_pair(y,i);
    v[p].push(u);
  }
  vector<string> ans(m);
  rep1(i,n){
    auto q = v[i];
    int cnt=0;
    while(!q.empty()){
      cnt++;
      auto p = q.top();q.pop();
      int t = p.second;
      ans[t]=assembleId(i,cnt);
    }
  }
  for(auto e:ans){
    cout << e << endl;
  }
  return 0;
}

Measured memory_bytes: 12748
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N,K,R,S,P;
  string T;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;
  ll ans = 0;
  ll count[T.length()];
  for(int i=0;i<K;i++){
    count[i]=0;
    if(T[i]=='r') ans += P;
    if(T[i]=='s') ans += R;
    if(T[i]=='p') ans += S;
  }
  for(int i=K;i<T.length();i++){
    count[i]=0;
    if(T[i]!=T[i-K]){
      if(T[i]=='r') ans += P;
      if(T[i]=='s') ans += R;
      if(T[i]=='p') ans += S;
      count[i] = 0;
    }else if(count[i-K]%2!=0){
      if(T[i]=='r') ans += P;
      if(T[i]=='s') ans += R;
      if(T[i]=='p') ans += S;
      count[i] = count[i-K]+1 ;
    }else{
      count[i] = count[i-K]+1 ;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4076
M, D = map(int,input().split())
D10 = D//10
D1 = D%10
count = 0
for i in range(21,D+1):
    i10 = i//10
    i1 = i%10
    if i10<2 or i1<2:
        count+=0
    elif i10*i1<=M:
        count +=1
print(count)
    

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
def dfs(v, par=-1):
  res = 0
  for nv in T[v]:
    if nv == par:
      continue
    res ^= dfs(nv, v)+1
  return res
if dfs(0) == 0:
  print("Bob")
else:
  print("Alice")

Measured memory_bytes: 139584
n,k = map(int,input().split())
arr = [0 for i in range(100000)]
for i in range(n):
    a,b = map(int,input().split())
    a-=1
    arr[a] += b

acc = 0
# print(arr[:4])
for i in range(100000):
    acc += arr[i]
    # print(i,acc)
    if acc >= k:
        print(i+1)
        break



Measured memory_bytes: 45168
S = input()
result = 0
for i in range(len(S)):
  checker = 0
  if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
    checker += 1
    for j in range(i+1,len(S)):
      if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
        checker += 1
      else:
        break
  result = max(result,checker)
print(result)

Measured memory_bytes: 9080
H,W=map(int,input().split())
if W==1 or H==1:
	print(1)
elif H%2==0 and W%2==0:
	print((H//2)*(W))
elif H%2==1 and W%2==0:
	print(H*W-((H//2)*(W//2))-((H//2)+1)*(W//2))
elif H%2==0 and W%2==1:
	print(H*W-((W//2)*(H//2))-((W//2)+1)*(H//2))
else:
	print(H*W-((H//2)*((W//2)+1))-((H//2)+1)*(W//2))

Measured memory_bytes: 3064
from math import sqrt

n = int(input())
lim_n = int(sqrt(n*2))
result = [0] * n

for i in range(2, lim_n+1):
    for j in range(2, i+1):
        for k in range(2, j+1):
            p = i**2+j**2+k**2
            if p > 2*n:
                break
            if p % 2 == 1:
                continue
            if (j + k) - i < 2:
                continue
            if i == j and j == k:
                if i  % 2 ==1:
                    continue
                result[p//2-1] += 1
            elif i != j and j != k:
                result[p//2-1] += 6
            else:
                result[p//2-1] += 3

for item in result:
    print(item)

Measured memory_bytes: 9392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e5 + 5;

int n;
int a[N], ans[N];

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        ans[a[i]] = i;
    }
    for(int i = 1; i <= n; i++) {
        cout << ans[i] << (i == n ? "\n" : " ");
    }
}

int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 4376
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		String ans = solve();
		System.out.println(ans);
	}
	
	private static String solve() {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		
		Map<Character, Boolean> flags = new TreeMap<>();
		String allChars = "abcdefghijklmnopqrstuvwxyz";
		for (int i = 0; i < allChars.length(); i++) {
			flags.put(allChars.charAt(i), false);
		}
		
		for (int i = 0; i < str.length(); i++) {
			flags.put(str.charAt(i), true);
		}
		
		for (Character c : flags.keySet()) {
			if (flags.get(c) == false) return c.toString();
		}
		
		return "None";
	}
}

Measured memory_bytes: 26444
package main

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

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) 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 main() {
	sc := NewScanner()
	_, M := sc.nextInt(), sc.nextInt()
	is := make([]int, 100000)
	for i := 0; i < M; i++ {
		a := sc.nextInt()
		b := sc.nextInt()
		if is[a-1] == 0 || b-1 < is[a-1] {
			is[a-1] = b - 1
		}
	}
	count := 0
	end := -1
	for start, v := range is {
		if v == 0 {
			continue
		}
		nend := v
		if start < end {
			if nend < end {
				end = nend
			}
		} else {
			count++
			end = nend
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin >> n >> k;
  ll dp[n];
  ll h[n];
  rep(i,n) cin >> h[i];
  rep(i,n) dp[i]=1e10;;
  dp[0]=0;    
  rep(i,n){
    rep1(j,k){
      if(i-j>=0){
	dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  cout << dp[n-1] << endl;
  return 0;
    

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    vector<int> s(3);cin>>s[1]>>s[2]>>s[0];
    sort(s.begin(),s.end());
    cout<<s[0]<<" "<<s[1]<<" "<<s[2]<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int64_t n, y;
  cin >> n >> y;
  int tmp = 0;
  rep(i, n+1) {
    rep(j, n-i+1) {
      if (n-i-j == (y-10000*i-5000*j)/1000) {
        cout << i << ' ' << j << ' ' << n-i-j << endl;
        tmp++;
        break;
      }
    }
    if (tmp > 0) {
      break;
    }
  }
  if (tmp == 0) {
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  }
}

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

using namespace std;

typedef long long ll;

vector<int> AdjList[100005];
int visit[100005];

void dfs(int x){
	visit[x] = 1;
	for (auto it : AdjList[x]){
		if (visit[it]) continue;
		dfs(it);
	}
}


ll N, M, Q, A, B, C, cnt;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= M; ++i){
		cin >> A >> B >> C;
		AdjList[A].push_back(B);
		AdjList[B].push_back(A);
	}
	for (int i = 1; i <= N; ++i){
		if (!visit[i]){
			dfs(i);
			cnt++;
		}
	}
	cout << cnt << '\n';
}

Measured memory_bytes: 9216
#include<stdio.h>
int main(void)
{
    static int i,j=0,n,x,A[1000000],tmp;
    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d", &A[i]);
    x=A[n-1];
    for(i=0;i<n-1;i++){
        if(A[i]<=x){
            tmp=A[i];
            A[i]=A[j];
            A[j]=tmp;
            j++;
        }
    }
    tmp=A[j];
    A[j]=A[n-1];
    A[n-1]=tmp;
    printf("%d",A[0]);
    for(i=1;i<n;i++){
        if(i==j) printf(" [%d]",A[j]);
        else     printf(" %d",A[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 996
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	num, _ := strconv.Atoi(a + b)
	if isSquare(num) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isSquare(num int) bool {
	for i := 1; ; i++ {
		if i*i == num {
			return true
		} else if i*i > num {
			return false
		}
	}
}


Measured memory_bytes: 512
H, W, K = map(int, input().split())
hp = {-2: 1, -1: 1, 0: 1, 1: 2, 2: 3, 3: 5, 4: 8, 5: 13, 6: 21, 7: 34}
d = {} #d[h, s, g]
for s in range(1, W + 1):
  for g in range(1, W + 1):
    if s == g:
      d[0, s, g] = 1
    else:
      d[0, s, g] = 0
for h in range(1, H + 1):
  for s in range(1, W + 1):
    for g in range(1, W + 1):
      p = d[h - 1, s, g] * hp[s - 2] * hp[W - s - 1]
      if s > 1:
        p = p + d[h - 1, s - 1, g] * hp[s - 3] * hp[W - s - 1]
      if s < W:
        p = p + d[h - 1, s + 1, g] * hp[s - 2] * hp[W - s - 2]
      p = p % 1000000007
      d[h, s, g] = p
print(d[H, 1, K])

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

using ll=int64_t;

int main() {
  ll N; cin >>N;
  vector<ll> ans(86+1);
  ans[0]=2;
  ans[1]=1;
  if (2<=N) {
    rep_eq(i,2,N) {
      ans[i]=ans[i-1]+ans[i-2];
    }
  }
  cout <<ans[N] <<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int a,b;
	cin>>a>>b;
	if(a<1||a>9||b<1||b>9)cout<<-1;
	else cout<<a*b;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  string S;
  cin >> S;
  S[3] = '8';
  cout << S << endl;
}


Measured memory_bytes: 764
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;

int dp[1000010][2];
string S;
int N;
bool done[1000010][2];
int rec(int i, bool flag) {
	if (i == N) {
		return flag;
	}
	if (done[i][flag])return dp[i][flag];
	done[i][flag] = true;
	int num = (S[i] - '0') + flag;
	int res1=0,res2 = 0;
	//自分が払う
	res1 += num;
	res1 += rec(i + 1, false);
	//相手が払う
	res2 += 10 - num;
	res2 += rec(i + 1, true);
	return dp[i][flag] = min(res1, res2);
}


void solve(){
	cin >> S;
	N = S.size();
	VREVERSE(S);
	print(rec(0, 0));
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Eratosthenes();
	//VSORT(sosuu);
	//REP(_, 100)test();
	//cerr << "done" << endl;
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 68828
#include <cstdio>
#include <cmath>
 
using namespace std;
 
int main()
{
	int n,t,a;
	scanf("%d %d %d",&n,&t,&a);
 
	double min=1000;
 
	int h,ans;
	for(int i=0;i<n;i++){
		scanf("%d",&h);
		if(abs(t-0.006*h-a)<min){
			min=abs(t-0.006*h-a);
			ans=i+1;
		}
	}
 
	printf("%d\n",ans);
 
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll m;
string S,T;
ll d;
ll ans;
ll M = 1000000007;
ll A[200001];
ll B[200001];
vector<ll> fac(5000001); //n!(mod M)
vector<ll> ifac(5000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

//ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//    ll ans = 1;
//    while(n != 0){
//        if(n&1) ans = ans*x % M;
//        x = x*x % M;
//        n = n >> 1;
//    }
//    return ans;
//}
//
//ll comb(ll a, ll b){ //aCbをmod計算
//    if(a == 0 && b == 0)return 1;
//    if(a < b || a < 0)return 0;
//    ll tmp = ifac[a-b]* ifac[b] % M;
//    return tmp * fac[a] % M;
//}
int main() {
    cin >> N>>m>>K;
    ll a=0;
    ll b=0;
    ll c=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(a<K){
            a+=A[i];
            b++;
        }
    }
    if(a>K){
        a-=A[b-1];
        b--;
    }
    for(int i=0;i<m;i++){
        cin >> B[i];
    }
    for(int i=0;i<=b;i++){
        while(a<=K&&c<m){
            a+=B[c];
            c++;
        }
        if(a>K){
            a-=B[c-1];
            c--;
        }
        if(ans<b-i+c){
            ans = b-i+c;
        }
        if(i!=b){
          a-=A[b-i-1];
        }
    }
    cout << ans << endl;
    
    }


Measured memory_bytes: 84512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if(a > k) {
        cout << a-k << " " << b;
    }
    else {
        cout << 0 << " " << max(0LL, a+b-k);
    }

    cout << endl;
    re0;
}

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

int main() {
  int n, q, S[10005], T[505];
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> S[i];
  cin >> q;
  for (int i = 0; i < q; ++i) cin >> T[i];
  int sum = 0;
  for (int i = 0; i < q; ++i) {
    for (int j = 0; j < n; ++j) {
      if (T[i] == S[j]) {
        sum++;
        break;
      }
    }
  }
  cout << sum << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define N 100005
#define M 10000000000
#define endl "\n"
using namespace std;

int m;


int Wt;

int wt[101];

long  long  val[101];


long long  dp[101][N];




long long maxCost(int n, int W)
{


	if (n - 1 < 0)
		return 0;

	if (W == 0)
		return 0;

	if (dp[n][W] != -1)
		return dp[n][W];


	if (wt[n - 1] <= W)
		return dp[n][W] = max(val[n - 1] + maxCost( n - 1, W - wt[n - 1]), maxCost(n - 1, W));
	else return dp[n][W] = maxCost(n - 1, W);


}


int32_t main()
{


	cin >> m >> Wt;


	for (int i = 0; i < m; ++i)
	{
		cin >> wt[i] >> val[i];

	}


	memset(dp, -1, sizeof(dp));



	cout << maxCost(m, Wt) << endl;

}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
     cin>>a>>b>>c>>d;
  cmp=a+b;
  cmpp=c+d;
  if(cmp==cmpp)Cout("Balanced");
  else if(cmp<cmpp)Cout("Right");
                        else Cout("Left");
     

       
return 0;
}


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

int main(){
    int N, M; cin >> N >> M;
    int sum_of_days_for_homework = 0;
    for (int i = 0; i < M; i++)
    {
        int Ai;cin >> Ai;
        sum_of_days_for_homework += Ai;
    }
    cout << ((N - sum_of_days_for_homework < 0) ? -1 : N - sum_of_days_for_homework )<< endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
    // Your code here!
    int p,q,r;
    int min=10000;
    int a1=0,b1=0,i,k;
    scanf("%d %d %d",&p,&q,&r);
    
    if(p<=q && p<=r) {
        a1 = p;
        k = 0;
    }
    else if(q<=p && q<= r) {
        a1 = q;
        k=1;
    }
    else {
        a1 = r;
        k=2;
    }
    
    for(i=0;i<3;i++){
        if(i == k) continue;
        if(i==0 ) b1 = a1+p;
        else if(i==1) b1 = a1+q;
        else b1 = a1+r;
        if(min > b1) min = b1;
    }
    
    printf("%d\n",min);
    return 0;
}


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

using namespace std;

int N;
double array1[1002];
double array2[1002];
double T;
double A;

int main(){
  cin >> N;
  cin >> T >> A;
  for(int i=0;i!=N;i++){
    cin >> array1[i];
    array1[i]=A-T+(array1[i]*0.006);
    array1[i]=abs(array1[i]);
    array2[i]=array1[i];
  }
  sort(array2,array2+N);
  for(int i=0;i!=N;i++){
    if(array2[0]==array1[i]){
      cout << i+1 << endl;
    }
  }
}


Measured memory_bytes: 256
/*
** Author: MAC45
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt","wt",stdout);
    ll S;
    string K;
    cin >> S >> K;
    if (K.size() <= S)
        cout << K << endl;
    else
    {
        for (int i = 0; i < S; i++)
            cout << K[i];
        cout << "..." << endl;
    }
    return 0;
}


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

int main(){
    int N, Y;
    cin >> N >> Y;
    for (int x=0; x<=N; x++) {
        for (int y=0; y<=N-x; y++) {
            int z = N - x - y;
            if (10000*x + 5000*y + 1000*z == Y) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout <<  -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
from math import sqrt
def isprime(num):
    if num == 2:
        return True
    if num < 2 or num % 2 == 0:
        return False
    for i in range(3,int(sqrt(num))+1,2):
        if num % i == 0:
            return False
    return True

a = int(input())
c = 0
for j in range(a):
    b = int(input())
    c += isprime(b)
print(c)


Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define gc getchar
#define ll long long
#define lb(x) ((x)&(-(x)))
int n,ans;struct node {int id,v;}a[N];
int rd()
{
    bool fl=0;int res=0;char c=0;
    while(!isdigit(c)) fl|=c=='-',c=gc();
    while(isdigit(c)) res=(res<<1)+(res<<3)+(c&15),c=gc();
    return fl?-res:res;
}
bool cmp(node x,node y) {return x.v<y.v;}
int main()
{
    n=rd();for(int i=1;i<=n;++i) a[i].id=i,a[i].v=rd();sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;++i) if((i&1)!=(a[i].id&1)) ++ans;printf("%d\n",ans>>1);
}


Measured memory_bytes: 1024