akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		String n = sc.next();

		if(n.equals("A")){
			System.out.println("T");
		}else 	if(n.equals("G")){
			System.out.println("C");

		}else 	if(n.equals("C")){
			System.out.println("G");

		}else 	if(n.equals("T")){
			System.out.println("A");

		}


 
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
  int x,y;
  cin >> x >> y;
  if(y%2 == 0 && 0 <= 2*x-y/2 && 2*x-y/2 <= 50){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n;cin>>n;
    vector<int> a(n+1),b(n+1),ans;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=n;i>=1;i--){
        int sum = 0;
        for(int j=i+i;j<=n;j+=i){
            sum ^= b[j];
        }
        b[i]=sum^a[i];
        if(b[i])ans.push_back(i);
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size()){
        cout<<ans[i]<<" ";
    }
  cout <<endl;
}


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int , int> P;
typedef vector<P> vP;
typedef vector<vector<int>> vvi;
typedef vector<vector<P>> vvP;
#define INF 1000000
int main() {
	int n, t;
	cin >> n >> t;
	t = t / 2;
	vi A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	int m = 0;
	vi ans(n);
	for (int i = n - 1; i >= 0; i--) {
		ans[i] = max(0, m - A[i]);
		m = max(m, A[i]);
	}
	/*for (int i = 0; i < n; i++) {
		cout << A[i] << " " << ans[i] << endl;
	}*/
	sort(ans.begin(), ans.end());
	//for (int i = 0; i < n; i++)cout << ans[i] << endl;
	int r = 0;
	for (int i = n - 1; i > 0; i--) {
		r++;
		if (ans[i] != ans[i - 1])break;
		else if (ans[0] == ans[1]&&i==1)r++;
	}
	
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
   long long int a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {ans+=k;
    }
    else
    {
      if(k>a)
      {ans+=a;
       k=k-a;
         }
      if(k<=b && k>0)
      {ans+=0;
      }
      else
      {
       if(k>b)
        { k=k-b;
         }
       if(k<=c && k>0)
      {ans+=(-k);
       k=k-c;
       }
      }
    }
   cout<<ans;
    

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int cnt[26];
long long f(long long x)
{
	return x*(x+1)/2;
}
int main()
{
	string s;
	cin >> s;
	long long ans=f(s.size());
	for (char c:s)
	cnt[c-'a']++;
	for (int i=0;i<26;i++)
	ans-=f(cnt[i]);
	cout << ans+1;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,T,S;
    cin >> N >> T >> S;
    vector<ll> A(N),B(N);
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
    }
    vector<vector<ll>> dp(N+5, vector<ll> (S+5,0));
    for(int i=0; i<N; i++){
        for(int j=0; j<=S; j++){
            chmax(dp[i+1][j],dp[i][j]);
            if(j+B[i] > S) continue;
            chmax(dp[i+1][j+B[i]], dp[i][j] + A[i]);
        }
    }
    vector<vector<ll>> dp2(N+5, vector<ll> (T-S+5,0));
    for(int i=N; i>0; i--){
        for(int j=0; j<=T-S; j++){
            chmax(dp2[i][j],dp2[i+1][j]);
            if(j+B[i-1] > T-S) continue;
            chmax(dp2[i][j+B[i-1]],dp2[i+1][j]+A[i-1]);
        }
    }
    ll ans = 0;
    for(int i=0; i<=N; i++){
        chmax(ans,dp[i][S]+dp2[i+1][T-S]);
    }
    cout << ans << enld;
    return 0;
}


Measured memory_bytes: 73920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    ll sum = 0;
    for (int i = 0; i < s.size(); i++)
    {
        sum += (s[i] - '0');
    }
    if (sum % 9 == 0)
        cout << "Yes\n";
    else
    {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int main(){
int N,M;
  cin>>N>>M;
  vector<int>S(N);
  for(int i=0;i<N;i++)
    cin>>S.at(i);
  vector<int>T(M);
  for(int i=0;i<M;i++)
    cin>>T.at(i);
  vector<vector<int>>dp(1+N,vector<int>(1+M,1));
  for(int i=1;i<=N;i++){
  for(int j=1;j<=M;j++){
  if(S.at(i-1)==T.at(j-1))
    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    else
      dp[i][j]=(mod+dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
  
  }
  }cout<<dp[N][M]<<endl;
   return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>
#include <string.h>

int main(){
	
	char tarou[1000],hanako[1000];
	int n,t_point=0,h_point=0;
    
	scanf("%d", &n);
	for(;n>0;n--){
		scanf(" %s %s", tarou, hanako);
		if(strcmp(tarou, hanako)>0){
			t_point+=3;
		}else if(strcmp(tarou, hanako)==0){
			t_point+=1;
			h_point+=1;
		}else if(strcmp(tarou, hanako)<0){
			h_point+=3;
		}
	}
    
	printf("%d %d\n",t_point,h_point);
    
    return 0;

}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int n;
  cin>>n;
  int a[n];
  int c=0;
  int s=0;
  int m=1000000000;
  for(int i=0;i<n;i++){
    cin>>a[i];
    c+=(a[i]<0?1:0);
    s+=abs(a[i]);
    m=min(m,abs(a[i]));
  }
  cout<<(c%2==0?s:s-2*m)<<endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;

    vector<int> vecB(n-1);
    for(int i=0; i<n-1; i++)
        cin >> vecB.at(i);
    
    // 数列Aを予測
    vector<int> vecA(n);
    vecA[0] = vecB[0];    vecA[1] = vecB[0];
    for(int i=1; i<n-1; i++){
        vecA[i+1] = vecB[i];

        if(vecA[i] > vecB[i])
            vecA[i] = vecB[i];
    }

    // 結果
    int res = 0;
    for(int i=0; i<n; i++)
        res += vecA[i];

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
main = do
    str <- getLine
    let (n:x:_) = map read $ words str
    if ((n,x) == (0,0)) then
        return ()
    else do
        print $ length [(a,b,c) | a <- [1..(n-2)], b <- [(a+1)..(n-1)], c <- [(b+1)..n], a+b+c==x]
        main

Measured memory_bytes: 4596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();

        int number = x / 100;

        if (x >= 100 * number && 105 * number >= x) {
            System.out.println(1);
            return;
        }
        System.out.println(0);
    }
}

Measured memory_bytes: 23380
<?php
$n = fgets(STDIN);
$array = array();
for ($i = 1; $i <= $n; $i++) {
	$x = $i;
	if ($x % 3 == 0) {
		$array[] = $i;
		continue;
	}
	while ($x) {
		if ($x % 10 == 3) {
			$array[] = $i;
			break;
		}
		$x = floor($x / 10);
	}
}

echo " ".implode(" ", $array)."\n";

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

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

    stringstream ss;
    ss << N;
    int index = ss.str().find('9');
    if (index < 0) {
        cout << "No";
    } else {
        cout << "Yes";
    }
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CCountOrder {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        vector<int> P(N), Q(N), Original(N);
        REP(i,0,N) in >> P[i];
        REP(i,0,N) in >> Q[i];
        REP(i,0,N) Original[i] = i+1;
        int cnt = 1, a = 1, b = 1;
        while (next_permutation(all(Original))) {
            cnt++;
            if (equal(all(P),Original.begin())) a = cnt;
            if (equal(all(Q),Original.begin())) b = cnt;
        }
        out << abs(a-b) << "\n";
    }
};


signed main() {
    CCountOrder solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N = 500010;
namespace treeArr{
    struct node{
        int num[26];
    }tree[N * 5];
    int n;
    int lowbit(int x){
        return x & (-x);
    }
    void update(int pos, char s, int num){
        for(int i = pos; i <= n; i += lowbit(i)){
            tree[i].num[s - 'a'] += num;
        }
    }

    int query(int pos, int v){
        int res = 0;
        while(pos){
            res += tree[pos].num[v];
            pos -= lowbit(pos);
        }
        return res;
    }
}
char s[N];
int main(){
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    treeArr::n = n;
    for(int i = 0; i < n; i ++){
        treeArr::update(i + 1, s[i], 1);
    }

    int q;
    scanf("%d", &q);
    while(q --){
        int did;
        scanf("%d", &did);
        if(did == 1){
            int pos;
            char c[2];
            scanf("%d %s", &pos, c);
            treeArr::update(pos, s[pos - 1], -1);
            treeArr::update(pos, c[0], 1);
            s[pos - 1] = c[0];
        }
        else if(did == 2){
            int l, r;
            scanf("%d %d", &l, &r);
            int num = 0;
            for(int i = 0; i < 26; i ++){
                if(treeArr::query(r, i) - treeArr::query(l - 1, i)){
                    num ++;
                }
            }
            printf("%d\n", num);
        }
    }
    return 0;
}


Measured memory_bytes: 53504
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long mod = 1e9+7;

int func(vector<int> a, int p, int k, int d) {
  int n = a.size();
  vector<int> b(n, 0);
  for(int i=0; i<n; i++) {
    int ii = (i+p)%n;
    b[ii] = k*2;
    k = a[ii] - k;
  }
  if(d == 1) return k;
  // cerr << k << endl;

  for(int i=0; i<n; i++) cout << b[i] << " ";
  cout << endl;
  return 0;
}

int main(void) {
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  int x = func(a, 0, 0, 1);

  func(a, 0, x/2, 0);


  return 0;
}

// EOF


Measured memory_bytes: 2544
#include<stdio.h>
#include<stdlib.h>

int main(void){

    int N,M,C,i,j,DD,ans;
    int *A,*B;

    scanf("%d%d%d",&N,&M,&C);

    A=malloc(sizeof(int)*N*M);
    B=malloc(sizeof(int)*M);

    for(i=0;i<M;i++){
        scanf("%d",&B[i]);
    }
    
    for(i=0;i<N;i++){
        
        for(j=0;j<M;j++){
        scanf("%d",&A[i*M+j]);
        }

    }

    ans=0;

    for(i=0;i<N;i++){
        
        DD=0;

        for(j=0;j<M;j++){
        DD=DD+A[i*M+j]*B[j];
        }

        if(DD>-C){
            ans+=1;
        }

    }
    
    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
	using namespace std;
	typedef long long int ll;
	
	#define pii                 pair<int,int>
	#define vi                  vector<int>
	#define vii                 vector<std::vector<int>> v;
	#define mem(dp,a)           memset(dp,a,sizeof dp)
	#define sonic               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#define pb(x)               push_back(x)
	#define mkp(x,y)             make_pair(x,y)
	#define all(c)              c.begin(), c.end()
	#define ff                  first
	#define ss                  second
	#define INF                 INT_MAX
	
	/* Bit Manipulation */
	
	#define isOn(S, j) (S & (1 << j))
	#define setBit(S, j) (S |= (1 << j))
	#define clearBit(S, j) (S &= ~(1 << j)) // to turn off
	#define toggleBit(S, j) (S ^= (1 << j))
	#define lowBit(S) (S & (-S)) // to get lsb
	#define setAll(S, n) (S = (1 << n) - 1)
	
	#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
	#define isPowerOfTwo(S) (!(S & (S - 1)))
	#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
	#define turnOffLastBit(S) ((S) & (S - 1))
	#define turnOnLastZero(S) ((S) | (S + 1))
	#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
	#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
	
	void printSet(int vS) {                         // in binary representation
	  printf("S = %2d = ", vS);
	  stack<int> st;
	  while (vS)
	    st.push(vS % 2), vS /= 2;
	  while (!st.empty())                         // to reverse the print order
	    printf("%d", st.top()), st.pop();
	  printf("\n");
	}
		
	/* Bit Manipulation Ends. */
		
	// Global variables declared here...
	
	//*******User-Defined Functions*********//
	
	
	
	//*******Functions end here************//
	
	//*******Main func starts**************//
	int main()
	{
	    sonic;
		int a;
		cin >> a;
		cout << a + a*a + a*a*a << endl;
	}
	//******Main Ends here****************//
	
	
	


Measured memory_bytes: 3640
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


n = int(input())

p = primes(55555)
ans = [v for v in p if v % 5 == 1]
print(*ans[:n])


Measured memory_bytes: 9748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    if(a <= 12 && a >= 6)
        b /= 2;
    else if(a < 6)
        b = 0;
    cout << b << endl;
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll a[202020],dp[202020][3],m[202020];
ll i,j,k,l,ans;
ll acc(ll a){
    if(a==0){
        return 2;
    }
    return a % 2;
}
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &a[i]);
    }
    fornum(i,0,N){
        m[i + 1] = m[i] + a[i];
    }
    fornum(i,0,N){
        ll d;
        d=m[i];
        d = min(d, dp[i][0]);
        dp[i + 1][0] = d + acc(a[i]);
        d = m[i];
        d = min(d, dp[i][0]);
        d = min(d, dp[i][1]);
        dp[i + 1][1] = d + acc(a[i] + 1);
        d = m[i];
        d = min(d, dp[i][1]);
        d = min(d, dp[i][2]);
        dp[i + 1][2] = d + acc(a[i]);
    }
    ans = LLONG_MAX;
    fornum(i,0,N+1){
        ll d = LLONG_MAX;
        fornum(j,0,3){
            d = min(dp[i][j],d);
        }
        ans = min(d + m[N] - m[i], ans);
        //printf("%lldd\n", ans);
    }

    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 8064
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
   long long a;
   cin>>a;
   vector<long long> vec(a);
   rep(i,a){
       cin>>vec.at(i);
   }
   long long maxv=-INF;
   long long minv=vec.at(0);
   for(int i=1;i<a;i++){
       maxv=max(maxv,vec.at(i)-minv);
       minv=min(minv,vec.at(i));
   }
   cout<<maxv<<endl;

}




Measured memory_bytes: 4420
# c - city savers
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sum = 0
rem = 0
for i in range(n):
    if (a[i] - rem) - b[i] >= 0:
        sum += b[i] 
        rem = 0
    else:
        if b[i] > a[i] - rem + a[i+1]:
            sum += a[i] - rem + a[i+1]
            rem = a[i + 1]
        else:
            sum += b[i]
            rem = b[i] - a[i] + rem
print(sum)

Measured memory_bytes: 18476
package main

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

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M, A, CC := nextInt(), nextInt(), []int{}, []ChangeCard{}

	for i := 0; i < N; i++ {
		A = append(A, nextInt())
	}
	for i := 0; i < M; i++ {
		CC = append(CC, ChangeCard{nextInt(), nextInt()})
	}

	fmt.Printf("%d\n", ABC127D(A, CC))
}

// ABC127D ...
func ABC127D(A []int, CC []ChangeCard) (res int) {
	sort.Sort(sort.IntSlice(A))

	sort.Slice(CC, func(i, j int) bool {
		if CC[i].c > CC[j].c {
			return true
		}
		return false
	})

	D := []int{}
	for len(D) <= len(A) && len(CC) > 0 {
		cc := CC[0]
		if len(CC) != 0 {
			CC = CC[1:]
		} else {
			CC = []ChangeCard{}
		}

		for i := 0; i < cc.b && len(D) <= len(A); i++ {
			D = append(D, cc.c)
		}
	}

	for i := 0; i < len(A); i++ {
		if i >= len(D) || A[i] > D[i] {
			res += A[i]
		} else {
			res += D[i]
		}
	}

	return
}

// ChangeCard ...
type ChangeCard struct {
	b int
	c int
}


Measured memory_bytes: 10724
#include <iostream>
#include <algorithm>

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

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int nums[3];
    std::cin >> nums[0] >> nums[1] >> nums[2];
    std::sort(nums, nums + 3);
    if (nums[0] == 5 && nums[1] == 5 && nums[2] == 7) {
        std::cout << "YES\n";
    } else {
        std::cout << "NO\n";
    }
    return 0;
}

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

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

int main() {
    fast_io;

    ll a,b,c,k;

    cin>>a>>b>>c>>k;

    ll ans=0;
    while(k>0) {
        while(k>0&&a>0) {
            ans+=1;
            a--;
            k--;
        }
        while(k>0&&b>0) {
            k--;
            b--;
        }
        while(k>0&&c>0) {
            k--;
            ans-=1;
            c--;
        }
    }
    cout<<ans<<endl;

}




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

int main()
{

string S;
string T;
string U;

int A;
int B;
    
cin >>S>>T>>A>>B>>U;    

if (S==U){
cout<<A-1<<" "<<B<<endl;
}       
    
else{
cout<<A<<" "<<B-1<<endl;
 }      
         
 }   
    
    

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

int main() {
  int N,D1,D2,ren=0;
  cin >> N;
  
  for (int i=0; i<N; i++) {
    cin >> D1 >> D2;
    if (D1 == D2) {
      ren++;
    }
    else {
      ren=0;
    }
    
    if (ren == 3) {
      break;
    }
  }
  
  if (ren == 3) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 3616
mod = 998244353
N, S = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0 for i in range(S+1)] for j in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += dp[i][j] * 2
        if j + A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j]
        dp[i+1][j] %= mod

print(dp[N][S])

Measured memory_bytes: 147040
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

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

int main(void) {

	int N, M;
	cin >> N >> M;

	vector<int> a(M),b(M);
	vector<int> answer(N);

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
	}

	for (int i = 0; i < N; i++) {
		answer[i] = 0;
	}

	for (int i = 0; i < M; i++) {
		int temp = a[i]-1;
		answer[temp]++;
		temp = b[i]-1;
		answer[temp]++;
	}

	for (int i = 0; i < N; i++) {
		cout << answer[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n,m,c = map(int, input().split())
brr = list(map(int, input().split()))
ans = 0
for i in range(n):
    s = 0
    arr = list(map(int, input().split()))
    for x,y in zip(arr, brr):
        s += x*y
    s += c
    if s > 0:
        ans += 1
print(ans)

Measured memory_bytes: 9092
using System;
class Program
    {
        static void Main(string[] args)
        {

            // 自分の得意な言語で
            // Let's チャレンジ！！

            var line = System.Console.ReadLine();
            var nums = line.Split(new char[] { ' ' });
            int M = Convert.ToInt32(nums[0]);
            int N = Convert.ToInt32(nums[1]);
            // 辞書順
            string ans = string.Empty;
            int small = Math.Min(M, N);
            if (small == M)
            {
                for (int i = 0; i < N; i++)
                {
                    ans += M.ToString();
                }
            }
            else
            {
                for (int i = 0; i < M; i++)
                {
                    ans += N.ToString();
                }
            }
            Console.WriteLine(ans);
        } 
    }

Measured memory_bytes: 11220
import sys
input = sys.stdin.readline
from collections import Counter, deque

INF = float('inf')

""" Input
S = input()
A = list(map(int, input().split()))
D = [int(input()) for _ in range(N)]
"""

def main():
    N = int(input())
    S, T = map(str, input().split())

    string = ""
    for i in range(N):
        string += S[i]
        string += T[i]
    print(string)


if __name__ == '__main__':
    main()


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

#define F first
#define S second
#define PB push_back
#define int ll

using namespace std;

typedef long long ll;

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, w;
	cin >> n >> w;

	vector<pair<int, int> > items;
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		items.PB({a,b});
	}

	int dp[100005];
	for(int i = 0; i < 100005; i++){
		dp[i] = INT_MAX;
	}

	dp[0] = 0;

	for(int i = 0; i < n; i++){
		for(int j = 100000; j >= items[i].S; j--){
			if(dp[j-items[i].S] == INT_MAX)	continue;
			dp[j] = min(dp[j], items[i].F + dp[j-items[i].S]);
		}
	}

	int ans = 0;
	for(int i = 0; i <= 100000; i++){
		if(dp[i] <= w)	ans = i;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef vector <int> VI;
typedef set <int> SI;
typedef map <int, int> MII;

VI K;
SI A, B, C;

int main() {
    int d;
    while ( cin >> d && d ) {
        K.clear();
        A.clear();
        B.clear();
        C.clear();

        int n, m;
        cin >> n >> m;
        for ( int i = 0; i < n - 1; ++ i ) {
            int dk;
            cin >> dk;
            A.insert( dk );
            B.insert( dk );
        }
        for ( int i = 0; i < m; ++ i ) {
            int kk;
            cin >> kk;
            K.push_back( kk );
            A.insert( kk );
            C.insert( kk );
        }

        MII D;
        int last1 = 0;
        for ( SI::iterator it = A.begin(); it != A.end(); ++ it ) {
            if ( B.count( *it ) ) {
                last1 = *it;
            }
            if ( A.count( *it ) ) {
                D[*it] = abs( *it - last1 );
            }
        }
        int last2 = d;
        for ( SI::reverse_iterator it = A.rbegin(); it != A.rend(); ++ it ) {
            if ( B.count( *it ) ) {
                last2 = *it;
            }
            if ( A.count( *it ) ) {
                D[*it] = min( D[*it], abs( *it - last2 ) );
            }
        }

        int res = 0;
        for ( int i = 0; i < m; ++ i ) {
            res += D[K[i]];
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#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 25

struct Info{
	Info(){

		value = 0,weight = 0;
	}
	Info(ll arg_value,ll arg_weight){
		value = arg_value;
		weight = arg_weight;
	}
	bool operator<(const struct Info &arg) const{

		return weight < arg.weight;
	}

	ll value,weight;
};

ll N,W;
ll POW[SIZE];
ll table_B[1 << 21];
Info info[45];


int main(){

	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%lld %lld",&N,&W);

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

		scanf("%lld %lld",&info[i].value,&info[i].weight);
	}

	if(N == 1){

		if(info[0].weight <= W){

			printf("%lld\n",info[0].value);
		}else{

			printf("0\n");
		}

		return 0;
	}

	vector<int> A,B;
	for(int i = 0; i < N/2; i++){

		A.push_back(i);
	}
	for(int i = N/2; i < N; i++){

		B.push_back(i);
	}

	vector<Info> vec_A,vec_B;
	for(int state = 0; state < POW[A.size()]; state++){

		ll sum_w = 0;
		ll sum_value =0;
		for(int loop = 0; loop < A.size(); loop++){
			if(state & POW[loop]){
				sum_w += info[A[loop]].weight;
				sum_value += info[A[loop]].value;
			}
		}
		vec_A.push_back(Info(sum_value,sum_w));
	}
	sort(vec_A.begin(),vec_A.end());

	for(int state = 0; state < POW[B.size()]; state++){

		ll sum_w = 0;
		ll sum_value =0;
		for(int loop = 0; loop < B.size(); loop++){
			if(state & POW[loop]){
				sum_w += info[B[loop]].weight;
				sum_value += info[B[loop]].value;
			}
		}
		vec_B.push_back(Info(sum_value,sum_w));
	}
	sort(vec_B.begin(),vec_B.end());

	table_B[0] = vec_B[0].value;
	for(int i = 1; i < vec_B.size(); i++){

		//ある重さ以下の最大価値を求める
		table_B[i] = max(table_B[i-1],vec_B[i].value);
	}

	int tail = vec_B.size()-1;
	ll ans = 0;
	for(int i = 0; i < vec_A.size(); i++){

		while(tail >= 0 && vec_A[i].weight+vec_B[tail].weight > W)tail--;
		if(tail < 0)break;

		ans = max(ans,vec_A[i].value+table_B[tail]);
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 44072
using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = ReadLineLongSplit();
			var a = n[0];
			var b = n[1];
			var c = n[2];
			var d = n[3];

			var ans = new List<long>();
			ans.Add(a*c);
			ans.Add(a*d);
			ans.Add(b*c);
			ans.Add(b*d);

			Console.WriteLine(ans.Max());
		}

		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n - 1, m - 1) / m;
		}

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

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

		public static long ReadLineLong()
		{
			return long.Parse(ReadLine());
		}

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

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

		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 18952
# 入力
N, K = map(int, input().split())
V = list(map(int, input().split()))

# 操作Aをa回、操作Bをb回、操作Cをc回実行したときの宝石の価値の合計値U(a, b, c)を求める。
# 各 a, b, c について U(a, b, c) の最大値を解とする。
ans = max(
    sum(sorted(V[:a] + V[(N - b):])[c:])
    for a in range(min(N, K) + 1)
    for b in range(min(N, K) - a + 1)
    for c in range(min(K - a - b, a + b) + 1)
)

# 出力
print(ans)


Measured memory_bytes: 43612
#include <vector>

#include <algorithm>
#include <string>
#include <iostream>
using namespace std;



int main(){
    int N,X;
    cin>>N>>X;
    
    vector<int> m=vector<int>(N);
    int num=N;
    int unused=0;
    int small;
    for (int i=0; i<N; i++) {
        cin>>m[i];
        unused+=m[i];
    }
    small=m[0];
    for (int i=1; i<N; i++) {
        if (small>m[i]) {
            small=m[i];
        }
    }
    X=X-unused;
    
    while (X>=small) {
        X=X-small;
        num++;
    }
    
    cout<<num;
    
}


Measured memory_bytes: 256
while True:
    H,W = list(map(int, input().split()))
    if W == 0 and H == 0:
        break
    w = 0
    h = 0
    for h in range(H):
        if h > 0 and h < H - 1:
            for w in range(W):
                if w > 0 and w < W - 1:
                    print(".", end="")
                else:
                    print("#", end="")
            print()
        else:
            for w in range(W):
                print("#", end="")
            print()
    print()



Measured memory_bytes: 7000
#include<iostream>
#include<cstring>
#include<stdbool.h>
using namespace std ;
bool coffee(char str[]){
    if(str[2]==str[3]&&str[4]==str[5]) return true;
    return false;
}

int main(){
    char str[6];
    cin >> str;
    if(coffee(str)){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		
		double p = 0;
		
		for (int i=1;i<=n;i++) {
			
			double tmp = 1.0/n;
			for (int j=i;j<k;j*=2) {
				tmp/=2;
			}
			
			p+=tmp;
		}
		System.out.println(p);



	}




}


Measured memory_bytes: 21972
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		char[] a = nextString().toCharArray();
		char[] b = nextString().toCharArray();
		char[] c = nextString().toCharArray();


		String ans = "NO";

		if(a[a.length-1]==b[0]&&b[b.length-1]==c[0])
			ans="YES";

		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N, 0);

    for(int i = 0; i < N-1; i++){
        int a;
        cin >> a;

        A[a-1]++;
    }

    for(int i = 0; i < N; i++){
        cout << A[i] << endl;
    }

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n; scanf("%d",&n);

	int cnt=0;
	rep(i,n){
		int a; scanf("%d",&a);
		if(a%2==1) cnt++;
	}
	puts(cnt%2==0?"YES":"NO");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
i64 f(i64 n, i64 x){
	if(n < 0) return 0;
	return n/x + 1;
}
int main() {
	// your code goes here
	i64 a,b,x;
	cin>>a>>b>>x;
	if(b<a) swap(a,b);
	//i64 ans = (b/x) +1 - (a/x);
	//if(a%x == 0) ans++;
	printf("%lld\n", f(b,x)-f(a-1,x));
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int N;
    cin >> N;
    vector<int> L;
    REP(i,2*N){
        int input;
        cin >> input;
        L.push_back(input);
    }
    sort(L.begin(),L.end());
    int ans = 0;
    REP(i,N){
        ans += L[2*i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    from collections import Counter    
    return sum(map(lambda x: x%2==1, Counter(A).values()))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 20992
def main():
    C = [list(map(int,input().split())) for _ in range(3)]

    for i in range(101):
        for j in range(101):
            for k in range(101):
                A = [i, j, k]
                B = [C[0][0]-A[0], C[1][1]-A[1], C[2][2]-A[2]]
                count = 0
                for l in range(3):
                    for m in range(3):
                        if C[l][m] == A[l]+B[m]:
                            count += 1
                if count == 9:
                    print('Yes')
                    return
    print('No')


if __name__ == '__main__':
    main()


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

int main(){
	int a,b;
	cin >> a >> b;
	int mx,mn;
	if(a > b){
		mx = a;
		mn = b;
	}
	else if (a < b){
		mx = b;
		mn = a;
	}
	bool ok = false;
	int ans = 0;
	for(int i = mn; i <= mx; i++){
		if(abs(a-i) == abs(b-i)){
			 ok = true;
			 ans = i;
			}
	}
	if(ok) cout << ans << endl;
	else cout << "IMPOSSIBLE" << endl;
}


// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3604
from collections import deque
h,w = map(int,input().split())
map_input = [list(input()) for i in range(h)]

queue = deque([])
for i in range(h):
    for j in range(w):
        if map_input[i][j]=='#':
            queue.append([j,i])

mx = [0,0,1,-1]
my = [1,-1,0,0]

ans = -1
def bfs(map_input,queue,ans):
    while queue:
        queue2 = deque([])
        ans+=1
        for x,y in queue:
            for i in range(4):
                nx = x+mx[i]
                ny = y+my[i]
                if 0<=nx<w and 0<=ny<h:
                    if map_input[ny][nx]=='#':
                        continue
                    map_input[ny][nx]='#'
                    queue2.append([nx,ny])

        queue = queue2
    return ans

ans = bfs(map_input,queue,ans)
print(ans)

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

int main() {
int n;
  cin>>n;
  string s;
  cin>>s;
  
  int maxe=0;
  for(int c=0;c<=s.size()-2;c++){
    int eq=0;
    for(int i=0;i<=c;i++){
      for(int j=i+1;j<=s.size()-1;j++){
        if(s[j]==s[i]){
          if(j>c){
          eq++;
          }
          break;
        }
      }
      }
      maxe=max(maxe,eq);
    }
  
  cout<<maxe<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
	int N, K;
	cin >> N >> K;
	vector<long int> x(N);
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	long int ans = 1000000000;
	for(int i=0;i+K-1<N;i++){
		long int left = x[i];
		long int right = x[i+K-1];
		if(left < 0 && right < 0) ans = min(0 - left, ans);
		else if(left < 0 && right > 0) ans = min(right - left + min(right, -1 * left), ans);
		else ans = min(right, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
//#include<string>
#include<iostream>
//#include<vector>
using namespace std;

float ca(int a, int per) {
    return (float)(a * (100 + per)) / 100.0;
}

float cb(int a, int per) {
    return (float)(a / (100 + per)) * 100.0;
}

int g(int a, int c, int per, int cnt) {
    int d = (int)ca(c, per);
    if (d == a) {
        return c;
    } else if (cnt > 100) {
        return c - cnt;
    } else {
        return g(a, c + 1, per, cnt + 1);
    }
}

int f(int a, int per) {
    float b = cb(a, per);
    int c = (int) b;
    return g(a, c, per, 0);
}



int sum(int a, int b, int per) {
    float ra = ca(a, per);
    float rb = ca(b, per);
    return (int)ra + (int)rb;
}

void ma(int pre, int after, int psum) {
    int max = 0;
    for (int a = 1; a < psum / 2 + 1; a++) {
        int b = psum - a;
        int ra = f(a, pre);
        int rb = f(b, pre);
        int m = sum(ra, rb, after);
        if (m > max) {
            max = m;
        }
    }
    cout << max << endl;
}

int main() {
    int pre, after, psum;
    while (true) {
        cin >> pre >> after >> psum;
        if (pre == 0 && after == 0 && psum == 0 ) break;
        ma(pre, after, psum);
    }
    return 0;
    
}




Measured memory_bytes: 3072
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

const string YES = "Yes";
const string NO = "No";

int main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  for (int i = 0; i < N - K; ++i)
  {
    if (A[i] < A[i + K])
      cout << YES << endl;
    else
      cout << NO << endl;
  }

  return 0;
}


Measured memory_bytes: 4852
import itertools
import sys

def f_row(L):
  for i in range(3):
    for j in range(3):
      if L[i][j] == False:
        break
      elif j == 2:
        return True
      else:
        continue
  return False

def f_col(L):
  for i in range(3):
    for j in range(3):
      if L[j][i] == False:
        break
      elif j == 2:
        return True
      else:
        continue
  return False
        
def f_rcross(L):
  for i in range(3):
    if L[i][i] == False:
      break
    elif i == 2:
      return True
    else:
      continue
  return False
      
def f_lcross(L):
  for i in range(3):
    if L[i][2-i] == False:
      break
    elif i == 2:
      return True
    else:
      continue
  return False

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

L = [[0]*3 for _ in range(3)]

for b in B:
  for i, j in itertools.product(range(3), repeat=2):
    if b == A[i][j]:
      L[i][j] = True
      if f_row(L) or f_col(L) or f_rcross(L) or f_lcross(L):
        print('Yes')
        sys.exit()
      break
print('No')

Measured memory_bytes: 62396
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x =sc.nextInt();
		int n =sc.nextInt();
		int min=0;
		int max=0;
		ArrayList p = new ArrayList<>();
		
	
		for(int i=0;i<n;i++) {
			p.add(sc.nextInt());
		}

		if(!(p.contains(x))) {
			System.out.println(x);
			System.exit(0);
		}
		
		
		for(int i=1;i<p.size();i++) {
			if(!(p.contains(x-i))) {
				System.out.println(x-i);
				System.exit(0);
			}
			else if(!(p.contains(x+i))) {
				System.out.println(x+i);
				System.exit(0);
				
			}
		}
		System.out.println(0);
		sc.close();
	}
}


Measured memory_bytes: 36016
s = input()
t = list(s)
x = 0
y = 0
z = 0
r = []

if t[0] == "A":
  x = 1
  
r.append(t[1])
r.append(t[len(t) - 1])

for i in range(2,len(t) - 1): 
  if t[i] == "C":
    y += 1
  else:
    r.append(t[i])

for j in r:
  if j.isupper():
    z = 1

if x == 1 and y == 1 and z == 0:
  print("AC")
else:
  print("WA")


Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var N = long.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        for(long i = 0;i < N;i++){
            a[i] -= i + 1;
        }
        Array.Sort(a);
        long b = a[N / 2];
        long sum = a.Select(x => Math.Abs(x - b)).Sum();
        Console.WriteLine(sum);
        
    }
}


Measured memory_bytes: 31392
n,k=map(int,input().split())
ll=[list(map(int,input().split())) for _ in range(k)]
dp=[0]*(3*n)
dp[0]=1
dp[1]=-1
for i in range(n):
    for l,r in ll:
        dp[l+i]+=dp[i]
        dp[i+r+1]-=dp[i]
    dp[i+1]=(dp[i]+dp[i+1])%998244353
print(dp[n-1])

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

int H[100005];
vector<int> X[100005];

int main() {

    int n, m;
    cin >> n >> m;

    for (int i=1; i<=n; i++)
        cin >> H[i];
    
    while(m--)
    {
        int u, v;
        cin >> u >> v;

        X[u].push_back(v);
        X[v].push_back(u);
    }

    int ans = 0;

    for (int i=1; i<=n; i++)
    {
        int maxx = 0;

        for (auto x : X[i])
            maxx = max(maxx, H[x]);
        
        if (maxx < H[i])
            ans++;
    }

    cout << ans << "\n";
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int ans = 1;
  for (int i = 0; i < N - 1; i++) {
    if (vec.at(i) != vec.at(i + 1)) {
      ans++;
    }
  }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static char[] l = new char[] {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	static String[][] map;
	static boolean[][] vmap;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int w = stdIn.nextInt();
			int h = stdIn.nextInt();
			if (h == 0 && w == 0) break;
			map = new String[h][w];
			vmap = new boolean[h][w];
			int x = 0;
			int y = 0;
			for(int i = 0; i < h; i++) {
				String a = stdIn.next();
				for(int j = 0; j < w; j++) {
					map[i][j] = String.valueOf(a.charAt(j));
					if(a.charAt(j) == '@') {
						x = j;
						y = i;
					}
				}
			}
			sorv(y,x);
			int ans = 0;
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					if(vmap[i][j]) ans++;
				}
			}
			System.out.println(ans);
		}
	}
	public static void sorv(int y,int x) {
		if(y < 0 || x < 0) return;
		if(y >= map.length || x >= map[y].length) return;
		if(map[y][x].equals("#")) return;
		if(vmap[y][x]) return;
		vmap[y][x] = true;
		sorv(y+1,x);
		sorv(y-1,x);
		sorv(y,x+1);
		sorv(y,x-1);
		
	}
}

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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String  n;        //文字列型変数ｎ

            n = Console.ReadLine();//キーボードから整数を読み込む

            if (n[0]=='9'  || n[1]=='9')//１文字目が’９’または
                Console.WriteLine("Yes");//２もじめが’９’なら”Yes"

            else
                Console.WriteLine("No");//それ以外は”No"

            Console.ReadKey();//キー入力待ち

          
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&a!=c)
    {
       printf("Yes");
    }
  else  if(a==c&&b!=a)
    {
         printf("Yes");
    }
  else  if(b==c&&a!=b)
    {
        printf("Yes");
    }
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
fn solve(mut xs: Vec<u8>) -> u8 {
    let mut result = 0;

    xs.sort();
    xs.reverse();

    for i in 0..xs.len() {
        if i % 2 == 0 {
            result += xs[i]
        } else {
            result -= xs[i]
        }
    }

    result
}

fn main() {
    let _ = read_none();
    let xs = read_vec();

    println!("{}", solve(xs));
}

fn read_none() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|c| c.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2144
<?php
fscanf(STDIN, '%d', $n);
$w = array_map('intval', explode(' ', trim(fgets(STDIN))));

$sum[0] = 0;
for($i = 1; $i <= $n; $i++) {
    $sum[$i] = $sum[$i - 1] + $w[$i - 1];
}
$min = 100000;
for($i = 1; $i < $n; $i++) {
    $s1 = $sum[$i];
    $s2 = $sum[$n] - $sum[$i];
    $d = abs($s1- $s2);
    $min = min($d, $min);
}
echo $min . PHP_EOL;

Measured memory_bytes: 4604
#include <iostream>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>

#define int64 long long int

using namespace std;

int main()
{
	int n, count;
	while(cin >> n){
		count = 0;
		for(int a=0; a<=9; a++){
			for(int b=0; b<=9; b++){
				for(int c=0; c<=9; c++){
					for(int d=0; d<=9; d++){
						if(a + b + c + d == n) count++;
					}
				}
			}
		}
		cout << count << '\n';
	}
	return 0;
}

Measured memory_bytes: 1160