akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string a,b,c;cin>>a>>b>>c;
    int na=a.length(),nb=b.length(),nc=c.length();
    if(a[na-1]==b[0]&&b[nb-1]==c[0])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector<lld>     adj[300005];
lld dp[300005];
void dfs(lld s,lld par)
{
    lld sz=adj[s].size();
    if(sz==1&&s!=1)          //leaf node base condition
    {
        dp[s]=1;
        return;
    }
    lld ans1=0;
    for(lld i=0;i<sz;i++)
    {
        if(adj[s][i]==par)
            continue;
        dfs(adj[s][i],s);
        ans1=ans1^dp[adj[s][i]];
    }
    dp[s]=1+ans1;
}
int main()
{
      ios;
      lld x,y,n,m;
      cin>>n;
      m=n-1;
      rep(i,0,m-1)
      {
          cin>>x>>y;
          adj[x].pb(y);
          adj[y].pb(x);  //if graph is directed delete this line
      }
      dfs(1LL,0LL);
      if(dp[1]==1)
        cout<<"Bob"<<endl;
      else
        cout<<"Alice"<<endl;
    return 0;
}


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

int main(){
  
  int n;
  string s = "", ans = "Three";
  cin >> n;
  rep(i, n){
    cin >> s;
    if(s == "Y") ans = "Four";
  }

  cout << ans << endl;

}

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

int main() {
  int n, k, mx = 0, d = 0;
  scanf ( "%d%d", &n, &k );
  for ( int i = 0, ai; i < n; ++i ) {
    scanf ( "%d", &ai );
    mx = max ( mx, ai );
    d = __gcd ( d, ai );
  }
  if ( k <= mx && k % d == 0 ) puts ( "POSSIBLE\n" );
  else puts ( "IMPOSSIBLE\n" );
  return 0;
}


Measured memory_bytes: 256
def min(a,b); a < b ? a : b; end
def distance(i,j); min(j - i, (X - i).abs + (Y - j).abs + 1); end

N, X, Y = gets.split.map(&:to_i)
D = Array.new(N - 1, 0)
(1 ... N).each do |i|
  (i + 1 .. N).each do |j|
    d = distance(i,j)
    D[d - 1] += 1
  end
end
puts D


Measured memory_bytes: 1788
#include<stdio.h>

int main(){
	int cup[3]={1,0,0},tmp;
	char X[5];

	while(scanf("%s",&X)!=EOF){
		tmp=cup[X[0]-'A'];
		cup[X[0]-'A']=cup[X[2]-'A'];
		cup[X[2]-'A']=tmp;
		
	}
	if(cup[0])
		printf("A\n");
	else if(cup[1])
		printf("B\n");
	else if(cup[2])
		printf("C\n");
	return 0;
}

Measured memory_bytes: 524
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
# define debug cerr<<"ERROR"<<endl
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1};
const int dy[]={0,1,0,-1,-1,1,-1,1}; 
const int inf=1e9,mod=1e9+7,N=1e6+5;

void solve(){	
	int n;
	cin>>n;
	deque<int>d;
	for(int i=0;i<n;++i){
		int x;
		cin>>x;
		if(!(i&1))d.push_back(x);
		else d.push_front(x);
	}
	if(n&1) while(!d.empty()){
		cout<<d.back()<<' ';
		d.pop_back();
	}
	else for(auto i:d)cout<<i<<' ';	
}

int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}


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

int main() {
  int N, A;
  cin >> N >> A;
  int M = N % 500;
  if (A >= 500) {
    cout << "Yes" << endl;
  }
  else if (M <= A) {
    cout << "Yes" << endl;
  }
  else if (M > A) 
    cout << "No" << endl;
  }

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
int a[100006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	for (int c = 1; c < n-1; c++) {
		int sum = 0;
		for (int k = 0; c*k < n - 1; k++) {
			sum += a[k*c];
			sum += a[n - 1 - k*c];
			if ((n - 1) % c == 0 && (n - 1 - k*c) <= k*c)break;
			if (c >= n - 1 - k*c)break;
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define Maxn 1000007
char s[Maxn];
int val[Maxn],sum[Maxn],r[Maxn];
bool flag[Maxn];
int n;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    memset(flag,false,sizeof(flag));
    int mx=0;
    for (int i=1;i<=n;i++)
    {
        if (s[i]=='1') val[i]=1;
        else if (s[i]=='0') val[i]=-1;
        else
        {
            flag[i]=true;
            val[i]=-1;
        }
        sum[i]=sum[i-1]+val[i];
        mx=max(mx,sum[i]);
    }
    r[n]=sum[n];
    for (int i=n-1;i;i--)
        r[i]=max(sum[i],r[i+1]);
    int tmp=0;
    for (int i=1;i<=n;i++)
        if (flag[i])
        {
            if (r[i]+tmp+2<=mx)
            {
                tmp+=2;
                val[i]=1;
            }
        }
    int mn=0;
    for (int i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+val[i];
        mn=min(mn,sum[i]);
    }
    int ans=mx-mn;
    ++mx;
    for (int i=1;i<=n;i++)
    {
        if (s[i]=='1') val[i]=1;
        else if (s[i]=='0') val[i]=-1;
        else
        {
            flag[i]=true;
            val[i]=-1;
        }
        sum[i]=sum[i-1]+val[i];
    }
    r[n]=sum[n];
    for (int i=n-1;i;i--)
        r[i]=max(sum[i],r[i+1]);
    tmp=0;
    for (int i=1;i<=n;i++)
        if (flag[i])
        {
            if (r[i]+tmp+2<=mx)
            {
                tmp+=2;
                val[i]=1;
            }
        }
    mn=0;
    for (int i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+val[i];
        mn=min(mn,sum[i]);
    }
    ans=min(ans,mx-mn);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 17456
import java.util.Scanner;
 
 
 
class Main {
 
	public static void main(String[] argv){
 
		Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();

int[] a = new int[n];
 
		for(int i = 0;i < n ;i++){ a[i] = sc.nextInt(); }
 
		sc.close();
 
	
 
 
		int count = 0;
 
		for(int i = 0;i<n;i++){
		if(a[a[i]-1]-1 == i) count++;
		}
 
		System.out.println(count/2);
 
 
 
 
	}
 
}

Measured memory_bytes: 32472
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var height = ToInt32(input[0]);
        var width = ToInt32(input[1]);
        var strs = new string[height];
        for(var i = 0; i < height; i++)
        {
            strs[i] = $"#{ReadLine()}#";
        }
        var outLine = "";
        for(var i = 0; i < width + 2; i++)
        {
            outLine += "#";
        }
        WriteLine(outLine);
        for(var i = 0; i < height; i++)
        {
            WriteLine(strs[i]);
        }
        WriteLine(outLine);
    }
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
const int NAX=2e5+5;
int n,a[NAX];
int ans[NAX];
vector<vector<int> > dp;
int bSearch(int x){
    int start=0,last=dp.size()-1,mid,ans=-1;
    while(start<=last){
        mid=(start+last)/2;
        if(dp[mid][dp[mid].size()-1]<x)
            start=mid+1;
        else{
            ans=mid;
            last=mid-1;
        }
    }
    return ans;
}
map<int,int> m;
stack<int> s;
void dfs(vector<vector<int> >&v,int i,int par){
    int ind=bSearch(a[i]);
    if(ind==-1){
        dp.pb({mod,a[i]});
        m[i]=dp.size()-1;
        ans[i]=dp.size();
        s.push(ans[i]);
    }
    else{
        ans[i]=max(s.top(),ind+1);
        m[i]=ind;
        s.push(ans[i]);
        dp[ind].pb(a[i]);
    }
    for(auto it: v[i]){
        if(it!=par){
            dfs(v,it,i);
        }
    }
    dp[m[i]].pop_back();
    s.pop();
}
int main(){
FASTIO;
cin>>n;
vector<vector<int> > v(n+1);
dp.reserve(n+1);
for(int i=1;i<=n;i++)
    cin>>a[i];
for(int i=0;i<n-1;i++){
    int x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
dfs(v,1,-1);
for(int i=1;i<=n;i++){
    cout<<ans[i]<<endl;
}
}


Measured memory_bytes: 49048
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

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

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  vec b(n+1,0);
  REP(i,n) b[i+1] = b[i]+a[i];

  map<int,int> mp;
  int ans = 0;
  REP(i,n+1) mp[b[i]%m]++;

  ITR(itr,mp) ans += itr->sc*(itr->sc-1)/2;

  cout << ans << endl;

  return 0;
}

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

inline long long read(){
	long long s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

long long n, t, a, ans;
double ch = 0x3f3f3f3f; 

int main(){
	n = read();
	t = read(), a = read();
	for (int i = 1; i <= n; i++){
		int h = read();
		double tem = t - h * 0.006;
		if (abs(tem - a) < ch){
			ans = i;
			ch = abs(tem-a);
		}
	} 
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n,m = MI()

if n==1 and m==1:
    print(1)
elif n==1:
    print(m-2)
elif m==1:
    print(n-2)
elif n==2 or m==2:
    print(0)
else:
    print(n*m-4-2*(n-2)-2*(m-2))

Measured memory_bytes: 77140
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int N;
	long long int x;
	int y = 0;
	int count = 0;
	scanf("%d%lld", &N, &x);
	long long int sum = 0;
	int a[110];
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	sort(a, a + N);

	if (sum == x) {
		printf("%d", N);
		return 0;
	}
	else if (sum < x) {
		printf("%d", N - 1);
		return 0;
	}
	else {
		for (int i = 0; i < N; i++) {
			x = x - a[i];
			if (x >= 0) {
				count++;
			}
			else {
				printf("%d", count);
				return 0;
			}
		}
	}

	printf("%d", count);
	return 0;
}


Measured memory_bytes: 128
const int N = 400005;
const int LG = 21;
const int MOD = 1e9 + 7;
const int INF = 1e9;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int n, m;
ll ans = 0;

signed main()
{
    srand(time(NULL));
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n >> m;
    if (abs(n - m) >= 2)
    {
        cout << ans;
        return 0;
    }
    if (abs(n - m) == 1)
    {
        cout << fact(n) * fact(m) % MOD << "\n";
        return 0;
    }
    cout << 2 * fact(n) * fact(m) % MOD;
}

/* Note:
Check constants at the beginning of the code.
N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
No def int long long for now.
*/


Measured memory_bytes: 9600
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K; cin >> N >> K;
	VI V(N);
	REP(i, N)cin >> V[i];
	int ans = -INF;

	eREP(i, N) {
		eREP(j, N - i) {
			if (i + j > K)continue;
			int cnt = 0;
			priority_queue<int, vector<int>, greater<int> > Q;
			REP(a, i) {
				cnt += V[a];
				if (V[a] < 0)Q.push(V[a]);
			}
			for (int a = N - 1; a > N - 1 - j; a--) {
				cnt += V[a];
				if (V[a] < 0)Q.push(V[a]);
			}
			int k = K - i - j;
			while (k && !Q.empty()) {
				cnt -= Q.top();
				Q.pop();
				k--;
			}
			chmax(ans, cnt);
		}
	}




	cout << ans << endl;

	return 0;
}



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

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

int main()
{
    int H, W;
    string mas[55];
    int sharp = 0;
    int min_cost[55][55];

    cin >> H >> W;
    for ( int i = 0; i < H; i++ ) {
        cin >> mas[i];
        sharp += count(begin(mas[i]), end(mas[i]), '#');
    }
    fill_n(*min_cost, 55 * 55, -1);
    min_cost[0][0] = 1;
    queue < pair < int , int > > que;
    que.emplace(0, 0);
    while ( !que.empty() ) {
        auto d = que.front(); que.pop();
        for ( int i = 0; i < 4; i++ ) {
            int ny = d.first + dy[i], nx = d.second + dx[i];
            if ( 0 <= ny && 0 <= nx && ny < H && nx < W && mas[ny][nx] == '.' && min_cost[ny][nx] == -1 ) {
                min_cost[ny][nx] = min_cost[d.first][d.second] + 1;
                que.emplace(ny, nx);
            }
        }
    }

    if ( min_cost[H - 1][W - 1] == -1 ) {
        cout << -1 << endl;
    } else {
        cout << H * W - sharp - min_cost[H - 1][W - 1] << endl;
    }

    return ( 0 );
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  int ans = 1500000000;
  int k = 0;
  for (int i = K - 1; i < N; i++) {
    int memo = h.at(i) - h.at(k);
    ans = min(ans, memo);
    k++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3776
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t;
lo cev;
string s;
vector<int> v;

int main(void){
	scanf("%lld %lld",&n,&m);
	cev=abs(n+m);
	if(cev%2==1){printf("IMPOSSIBLE\n");return 0;}
	printf("%lld\n",cev/2);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
typedef unsigned long long ull;
int main(){
  int n,m;
  while(true){
    std::cin >> n >> m;
    if(n+m == 0)break;
    std::string N[n+1];
    int M[n+1];
    ull sum = 0;
    for(int i=0;i<n;i++)std::cin >> N[i] >> M[i];

    for(int i=0;i<m;i++){
      std::string B;std::cin >> B;
      for(int j=0;j<n;j++){
	bool ok = true;
	for(int k=0;k<8;k++){
	  if(N[j][k] != '*'&& N[j][k] != B[k]){
	    ok = false;
	    break;
	  }
	}
	if(ok)sum+=M[j];
      }
    }
    std::cout << sum << std::endl;

  }
  return 0;
}

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

int n;

int main() {
	cin>>n;
	int d = n%10;
	if(d == 0 || d == 1 || d == 6 || d == 8) cout<<"pon";
	if(d == 2 || d == 4 || d == 5 || d == 7 || d == 9) cout<<"hon";
	if(d == 3) cout<<"bon";
	return 0;
}

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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == 0) {
        v.clear();
        return 0;
    }
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

int solve(int N, vi& a) {
    int sum = accumulate(ALL(a), 0);
    rep(i,N) a[i] *= N;
    rep(i,N) a[i] = abs(a[i] - sum);
    vii b(N);
    rep(i,N) b[i] = ii(a[i], i);
    sort(ALL(b));
    return b[0].second;
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int k,s;
	cin>>k>>s;
	int ans=0;
	for (int a=0;a<=k;a++)
		for (int b=0;b<=k;b++)
		{
			int c=s-a-b;
			if (c<=k&&c>=0)
				ans++;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<ll> v(n);
    REP(i,n) {
        cin >> v[i];
        v[i] -= i+1;
    }

    auto calc = [&](ll x) {
        ll ret = 0;
        REP(i,n) ret += abs(v[i]-x);
        return ret;
    };

    sort(ALL(v));
    ll d;
    if (n % 2 == 0) d = (v[n/2] + v[n/2-1]) / 2;
    else d = v[n/2];


    cout << calc(d) << '\n';


    return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int ans=n;
  for(int i=0;i<=n;i++)
  {
    int temp=0;
    int t=i;
	while(t>0)
    {
		temp+=(t%6);
      	t/=6;
    }
    t=n-i;
    while(t>0)
    {
      temp+=(t%9);
      t/=9;
    }
    ans=min(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt(); // \500
        int B = scanner.nextInt(); // \100
        int C = scanner.nextInt(); // \50
        int X = scanner.nextInt(); // 50*n

        int count = 0;
        for (int s=0; s <= A; s++) {
            for (int t=0; t <= B; t++) {
                for (int u=0; u <= C; u++) {
                    if (500 * s + 100 * t + 50 * u == X) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
const int mod =1e9+7;
int main(){
  int n;
  cin>>n;
ll a=1;
for(int i=1;i<=n;i++){
  a*=i;
  if(a>mod)a%=mod;
  }
  cout<<a<<endl;
}


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

int main (){
	int n;
	cin>> n;
	int a = n%10;
	if (a == 2 || a==5 || a==9 ||a== 7 || a==4)
		cout << "hon\n";
	else if (a == 0 || a== 1 ||a == 6 || a==8)
		cout << "pon\n";
	else
		cout << "bon\n"; 
	return 0;
}

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

int main() {
int A,B,C;
  cin>>A>>B>>C;
  if(A==B && B!=C){
  cout<<"Yes";
  }
  else if(B==C && C!=A){
  cout<<"Yes";
  }
  else if(A==C && C!=B){
  cout<<"Yes";
  }
  else{
  cout<<"No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 200000 + 233;
const LL P = 1000000007;
int n, m;
char s[maxN];
LL f[maxN];

LL purity() {
	LL f00 = 1, f11 = 1, f01 = 0, f10 = 0;
	// '11' is not OK
	for(int i = 2; i <= n; ++i) {
		LL g00 = f00 + f01, g01 = f00,
		   g10 = f10 + f11, g11 = f10;
		f00 = g00 % P; f01 = g01;
		f10 = g10 % P; f11 = g11;
	}
	return (f00 + f01 + f10) % P;
}

LL recur(int lim) {
	// sum( x ^ (p + 1) )
	// sum( (c + 1) * x ^ (p + 1) )
//	display(lim);
	memset(f, 0, sizeof(f));
	f[0] = 1; f[1] = 0; f[2] = 1; f[3] = 0;
	for(int i = 4; i <= n; ++i) {
		f[i] = f[i - 2] * 2 % P;
		if(i - lim - 3 >= 0) f[i] = (f[i] + P - f[i - lim - 3]) % P;
	}
//	displaya(f, 0, n);
	LL ans = 0;
	for(int i = 1; i <= lim; i += 2) if(n - i - 1 >= 0)
		(ans += f[n - i - 1] * (i + 1)) %= P;
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m >> (s + 1);
	assert((int)strlen(s + 1) == m);
	char major = s[1], minor = (int)'R' + 'B' - major;
	int cons = 0;
	int mn = maxN;
	bool first = true;
	for(int i = 1; i <= m; ++i) {
		if(s[i] == major) cons++;
		else {
			if(first) chmin(mn, cons | 1), cons = 0, assert(s[i] == minor), first = false;
			else if(cons & 1) chmin(mn, cons), cons = 0, assert(s[i] == minor);
			else cons = 0;
		}
	}
	if(mn == maxN) cout << purity() << endl;
	else cout << recur(mn) << endl;
	return 0;
}


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

int main()
{
    string s, ss;
    ll t, n, m;
    while(cin>>n>>m)
    {
        for(int i=1; i<=3; i++)
        {
            if(i!=m && i!=n){cout<<i<<endl;break;}
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long A[2<<17],B[2<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	long ans=0;
	for(int t=0;t<250;t++)
	{
		for(int i=t&1;i<N;i+=2)
		{
			long s=B[(i+N-1)%N]+B[(i+1)%N];
			long t=(B[i]-A[i])/s;
			ans+=t;
			B[i]-=t*s;
		}
	}
	for(int i=0;i<N;i++)
	{
		if(A[i]!=B[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3840
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void) {
	// your code goes here
	int n,m,i,a,b,f = 0;
	scanf("%d%d",&n,&m);
	int*x = (int*)malloc(sizeof(int)*(n+2));
	memset(x,n+2,0);
	for(i = 0;i<m;i++)
	{
		scanf("%d%d",&a,&b);
		if(a==1&& b!=n)
			{
				if(x[b] ==1)
					f = 1;
				else 
				x[b]=1;
				
			}
		else if(b==n&& a!=1)
		{
			if(x[a]==1)
				f = 1;
			else 
			x[a]=1;
		}
	}
		if(!f)printf("IM");
	printf("POSSIBLE");
	return 0;
}


Measured memory_bytes: 896
#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 argc, char const *argv[]) {
    int n, q, t;
    string name;
    queue<pair<string, int>> Q;

    cin >> n >> q;

    for (int i = 0; i < n; i++) {
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int elaps = 0, a;

    while (!Q.empty()) {
        u = Q.front(); Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if (u.second > 0) {
            Q.push(u);
        } else {
            cout << u.first << " " << elaps << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6172
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String str;
        Set<String> A = new HashSet<String>();
        for(int i = 0 ; i < N ; i++){
            str = sc.nextLine();
            A.add(str);
        }
        System.out.println(A.size()); 
        sc.close();
    }
}

Measured memory_bytes: 79176
n,l=(int(x) for x in input().split())
a=[]
for i in range(n):
  a.append(l+i)
m=abs(a[0])
for i in range(1,n):
  if abs(a[i])<m:
    m=abs(a[i])
s=0
for i in range(n):
  if abs(a[i])!=m:
    s+=a[i]
print(s)

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

int main(){
	vector<int> v(3,0);
	int s;
	for(int i = 0; i < 10; i++){
		sort(v.begin(),v.end());
		cin >> s;
		if(v[0] < s){
			v[0] = s;
		}
	}

	sort(v.begin(),v.end());
	for(int i = 0; i < 3; i++){
		cout << v[2-i] << endl;
	}

}

Measured memory_bytes: 3148
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
double num[60];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lf",&num[i]);
	}
	sort(num,num+n);
	
	for(int i=1;i<n;i++)
	{
		if(num[i]==0)
		continue;
		
		num[i]=(num[i]+num[i-1])/2;
		num[i-1]=0;
	}
	printf("%lf",num[n-1]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int h,n;
  cin >> h >> n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++)cin >> a.at(i) >> b.at(i);
  vector<int> dp(10001,INF);
  for(int i=0;i<n;i++){
    if(dp.at(a.at(i)) > b.at(i))dp.at(a.at(i)) = b.at(i);
  }
  //for(int i=1;i<=h;i++)cout << dp.at(i) << ' ';
  //cout << endl;
  for(int i=9999;i>0;i--){
    if(dp.at(i) > dp.at(i+1))dp.at(i) = dp.at(i+1);
  }
  //for(int i=1;i<=h;i++)cout << dp.at(i) << ' ';
  //cout << endl;
  for(int i=2;i<=h;i++){
    for(int j=1;j<i;j++){
      dp.at(i) = min(dp.at(i),dp.at(i-j) + dp.at(j));
    }
  }
  //for(int i=1;i<=h;i++)cout << dp.at(i) << ' ';
  //cout << endl;
  cout << dp.at(h) << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var target = new string[vals[0], vals[1]];
            foreach(var i in Enumerable.Range(0, vals[0]))
            {
                var j = 0;
                foreach(var str in Console.ReadLine().ToCharArray())
                {
                    target[i, j] = str.ToString();
                    j++;
                }
            }

            var result = true;
            foreach(var i in Enumerable.Range(0, vals[0]))
            {
                if (!result) break;
                foreach(var j in Enumerable.Range(0, vals[1]))
                {
                    if (!result) break;
                    if(target[i, j] == "#")
                    {
                        var newflag = false;
                        if (i > 0) newflag = newflag | target[i - 1, j] == "#";
                        if (i < vals[0] - 1) newflag = newflag | target[i + 1, j] == "#";
                        if (j > 0) newflag = newflag | target[i, j - 1] == "#";
                        if (j < vals[1] - 1) newflag = newflag | target[i, j + 1] == "#";
                        //Console.WriteLine($"{i}, {j}, {newflag}");
                        result = result & newflag;
                    }
                }
            }

            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13372
n, m = map(int, input().split())
ns, ms = [], []

for _ in range(n):
    a, b = map(int, input().split())
    ns.append((a, b))

for _ in range(m):
    a, b = map(int, input().split())
    ms.append((a, b))

for x, y in ns:
    diff = abs(x - ms[0][0]) + abs(y - ms[0][1])
    ans = 1
    for i, e in enumerate(ms):
        d = abs(x - e[0]) + abs(y - e[1])
        if d < diff:
            ans = i + 1
            diff = d
    print(ans)

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


int main() {
    char b;

    cin >> b;

    if( b == 'A'){
        cout << 'T';
    }
 

    if( b == 'T'){
        cout << 'A';
    }

    if( b == 'G'){
        cout << 'C';
    }

    if( b == 'C'){
        cout << 'G';
    }

}

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

int const N = 100000;
int x[N];

int main(){
	int n, m, v, p;
	scanf("%d%d%d%d", &n, &m, &v, &p);
	f(i, 0, n)scanf("%d", x + i);
	sort(x, x + n);
	reverse(x, x + n);
	int j = p;
	ll sm = 0;
	while (j < n){
		sm += x[j - 1];
		if (x[p - 1] - x[j] > m)break;
		int sad = j - (p - 1);
		int lft = v - (n - sad);
		int z = sad - lft;
		ll can = (ll)z * m;
		if (can < sm - (ll)x[j] * sad)break;
		++j;
	}
	printf("%d\n", j);
}

Measured memory_bytes: 640
n = int(input())

s = ''
for i in range(1, n+1):
    if i % 3 == 0:
        s += ' ' + str(i)
        continue
    
    dammy = i
    while dammy:
        if dammy % 10 == 3:
            s += ' ' + str(i)
            break
        else:
            dammy //= 10
print(s)


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

using namespace std;

int main(){
        int x, y;
        cin>>x>>y;
        if(x==2&&y==2){
                cout<<"Yes"<<endl;
        }
        else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
                cout<<"Yes"<<endl;
        }
        else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
                cout<<"Yes"<<endl;
        }
        else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#define N 4
#define N2 16
#define LIMIT 100

int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

typedef struct
{
    int f[N2];
    int space;
    int MD;
} puzzle;

puzzle state;
int limit;
int path[LIMIT];

void swap(int *a, int *b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}
int getALLMD(puzzle pz)
{
    int sum = 0;
    for (int i = 0; i < N2; i++)
    {
        if (pz.f[i] == N2)
            continue;
        sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
}

bool isSolved()
{
    for (int i = 0; i < N2; i++)
    {
        if (state.f[i] != i + 1)
            return false;
        return true;
    }
}

bool dfs(int depth, int prev)
{
    if (!state.MD)
        return true;
    if (depth + state.MD > limit)
        return false;

    int sx = state.space / N;
    int sy = state.space % N;
    puzzle tmp;

    for (int r = 0; r < 4; r++)
    {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if (tx < 0 || ty < 0 || tx >= N || ty >= N)
            continue;
        if (fmax(prev, r) - fmin(prev, r) == 2)
            continue;
        tmp = state;
        state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
        state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
        swap(&state.f[tx * N + ty], &state.f[sx * N + sy]);
        state.space = tx * N + ty;
        if (dfs(depth + 1, r))
        {
            path[depth] = r;
            return true;
        }
        state = tmp;
    }
    return false;
}

int deepening(puzzle in)
{
    in.MD = getALLMD(in);

    for (limit = in.MD; limit <= LIMIT; limit++)
    {
        state = in;
        if (dfs(0, -100))
        {
            char a[LIMIT] = {};
            for (int i = 0; i < limit; i++)
                a[i] += dir[path[i]];
            return strlen(a);
        }
    }

    return false;
}

int main()
{
    for (int i = 0; i < N2; i++)
        for (int j = 0; j < N2; j++)
            MDT[i][j] = fabs(i / N - j / N) + fabs(i % N - j % N);

    puzzle in;
    for (int i = 0; i < N2; i++)
    {
        scanf("%d", &in.f[i]);
        if (!in.f[i])
        {
            in.f[i] = N2;
            in.space = i;
        }
    }
    printf("%d\n", deepening(in));
    if (!isSolved())
        printf("failed\n");
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  string res = "";
  for (int i=0; i<s.size(); ++i) {
    if (i % 2 == 0) {
      res.push_back(s[i]);
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 512
n = int(input())

w = [input() for _ in range(n)]
f = True
lis = []
for i in range(0, n-1):
    end = w[i][-1:]
    next = w[i+1][:1]
    if end != next or w[i] in lis:
        f= False
        break
    else:
        lis.append(w[i])
if w[n-1] in lis:
    f = False
if f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vi> g(h + 2, vi(w + 2, 0));
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    char c;
    cin >> c;
    if(c == '#') g[i][j] = 1;
  }
  bool ans = true;
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    if(g[i][j] == 0) continue;
    bool ok = false;
    rep(k, 4) {
      ll ni = i + dir[k];
      ll nj = j + dir[k + 1];
      if(g[ni][nj] == 1) ok = true;
    }
    if(!ok) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 200050;
int N;
long long a_in[MAX_N], b_in[MAX_N];

int ret_bit[40];

int main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 1; i <= N; i++) {
        std::cin >> a_in[i];
    }
    for (int i = 1; i <= N; i++) {
        std::cin >> b_in[i];
    }

    long long tmp_mask = 0;
    for (int k = 0; k <= 30; k++) {
        tmp_mask += (1 << k);
        std::vector<long long> a, b;
        for (int i = 1; i <= N; i++) {
            a.push_back(a_in[i] & tmp_mask);
            b.push_back(b_in[i] & tmp_mask);
        }
        std::sort(a.begin(), a.end());
        std::sort(b.begin(), b.end());
        long long border01 = N - 1;
        long long border10 = N - 1;
        long long border11 = N - 1;
        long long cond11 = (1 << (k + 1)) + (1 << k);
        long long cond10 = (1 << (k + 1));
        long long cond01 = (1 << k);

        long long tmp = 0;
        for (int i = 0; i < a.size(); i++) {
            while (0 <= border11 && cond11 <= a[i] + b[border11]) {
                border11--;
            }
            while (0 <= border10 && cond10 <= a[i] + b[border10]) {
                border10--;
            }
            while (0 <= border01 && cond01 <= a[i] + b[border01]) {
                border01--;
            }
            tmp += N - 1 - border11;
            tmp += border10 - border01;
        }
        ret_bit[k] = tmp % 2;
    }

    long long ret = 0;
    for (int k = 0; k <= 30; k++) {
        if (ret_bit[k] == 1) {
            ret += (1 << k);
        }
    }

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

}



Measured memory_bytes: 10392
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
s = [a[0][0], sum(a[1])]
ans = s[0] + s[1]
for i in range(1, n):
    s[0] += a[0][i]
    s[1] -= a[1][i - 1]
    ans = max(ans, s[0] + s[1])
print(ans)

Measured memory_bytes: 3064