akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;
    ll count=K;
    while(1){
        if(count<=0)break;
        if(B>A)break;
        B*=2;
        count--;
    }
    if(B<=A){
        cout << "No" << endl;
        return 0;
    }
    while(1){
        if(count<=0)break;
        if(C>B)break;
        C*=2;
        count--; 
    }
    if(C<=B){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3644
import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String args[]){
    int n=sc.nextInt();
    int m=sc.nextInt();
    Map<Integer,List<Integer>> mp=new HashMap<>();
    
    for(int i=0;i<n;i++){
      int day=sc.nextInt();
      if(!mp.containsKey(day)){
        mp.put(day,new ArrayList<Integer>());
      }
      mp.get(day).add(sc.nextInt());
//      System.out.print(day+":");
    }
    long sum=0;
    PriorityQueue<Integer> pq=new PriorityQueue<Integer>(
      new Comparator<Integer>(){
        public int compare(Integer o1,Integer o2){
          return Integer.compare(o2,o1);
        }
      }
    );
//    System.out.println("\npq.isEmpty()="+pq.isEmpty());
    for(int i=1;i<=m;i++){
//      System.out.println("i="+i);
      if(mp.containsKey(i)){
//        System.out.println("  contains");
        pq.addAll(mp.get(i));
      }
//      System.out.println("  "+pq.toString());
      if(!pq.isEmpty()){
        sum=sum+pq.poll();
//        System.out.println("  sum="+sum);
      }
    }
    System.out.println(sum);
  }
}

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

int main(void){
	int h, w, bomb;
	cin >> h >> w;
	char s[h][w];
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			bomb = 0;
			if (s[i][j] == '#'){
				continue;
			}
			if (i != 0){
				if (j != 0){
					if (s[i-1][j-1] == '#'){
						bomb++;
					}
				}
				if (s[i-1][j] == '#'){
					bomb++;
				}
				if (j+1 != w){
					if (s[i-1][j+1] == '#'){
						bomb++;
					}
				}
			}
			if (j != 0){
				if (s[i][j-1] == '#'){
					bomb++;
				}
			}
			if (j+1 != w){
				if (s[i][j+1] == '#'){
					bomb++;
				}
			}
			if (i+1 != h){
				if (j != 0){
					if (s[i+1][j-1] == '#'){
						bomb++;
					}
				}
				if (s[i+1][j] == '#'){
					bomb++;
				}
				if (j+1 != w){
					if (s[i+1][j+1] == '#'){
						bomb++;
					}
				}
			}
			s[i][j] = char(bomb + '0');
		}
	}
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			cout << s[i][j];
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())

if k%2==1:
    print((n//k)**3)
    exit()
ans=0
#全部偶数か全部奇数

#偶数k%2==0
ans+=((n//k)**3)
#奇数and 余りが０、k/2
count=0
for i in range(1,n+1):
    if i%k==k//2:
        count+=1
ans+=count**3

print(ans)



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

int main()
{
	int n, count{}, h, w;
	scanf("%d%d%d", &n, &h, &w);
	for (int i = 0; i < n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		if (h <= a && w <= b)
			count++;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc163/tasks/abc163_d>
 問題文============================================================
 D - Sum of Large Numbers
 =================================================================
 解説=============================================================
 
 この問題は数字の付与されている10^100が 1...Nまでの総和よりもはるかに大きいので、
 N+1個の数からいくつの数を選ぶかで差別化することができる。
 
 選ぶ数の個数kを固定化させた時、和として作れる数は小さい方からk個選んだ数と大きい方からk個選んだ数の間の数は全てつくることができる。
 よって、小さい方からk個選んだ数と大きい方からk個選んだ数は選ぶ個数を決め打った時にO(1)で求まるので、
 この問題はO(N)で解ける。
 
 https://atcoder.jp/contests/abc163/submissions/12218002
 
 ================================================================
 */

const ll MOD = 1e9+7;
template<class Type>
Type solve(Type res = Type()){
    
    ll N,K; cin >> N >> K;
    
    // 少ない方からK個とる場合の総和
    ll L = K*(K-1)/2 % MOD;
    for(ll i = K-1; i <= N;i++){
        // 全部とる場合の総和
        ll R = i*(i+1)/2 % MOD;
        (res += (R-L+1+MOD)%MOD)%=MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	if(x==y)cout<<z;
	else if(x==z)cout<<y;
	else cout<<x;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int siz = s.size();
  vector<int> num(26,0);
  int mintime = 101;
  int time = 0;
  bool judge,all;
  char alpha;
  for(int i = 0;i < 26;i++){
    alpha = 'a' + i;
    judge = true;
    time = 0;
    string t = s;
    while(judge){
      judge = false;
      all = true;
      for(int j = 0;j < t.size()-1;j++){
        if(t[j] != t[j+1])all = false;
      }
      if(all == false)time++;
      else break;
      for(int j = 0;j < t.size()-1;j++){
        if(t[j] != alpha){
          t[j] = t[j+1];
          judge = true;
        }
      }
      t.pop_back();
    }
    if(mintime > time)mintime = time;
  }
  cout << mintime << endl;
}

Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

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

int main()
{
  // input & declare
  int tmp;
  std::vector<int> v1;
  std::vector<int> v3;
  std::vector<int> v2;
  for(int i = 0; i < 3; i++)
  {
    cin >> tmp;
    v1.push_back(tmp);
  }
  for(int i = 0; i < 3; i++)
  {
    cin >> tmp;
    v2.push_back(tmp);
  }
  for(int i = 0; i < 3; i++)
  {
    cin >> tmp;
    v3.push_back(tmp);
  }


  // process
  std::vector<int> as;
  std::vector<int> bs;
  as.push_back(0);
  bs.push_back(v1[0]);
  bs.push_back(v1[1]);
  bs.push_back(v1[2]);
  as.push_back(v2[0] - v1[0]);
  as.push_back(v3[0] - v1[0]);

  for (int i = 0; i < 3; i++){
    if (as[0] + bs[i] != v1[i] || as[1] + bs[i] != v2[i] || as[2] + bs[i] != v3[i]) {
      std::cout << "No" << '\n';
      exit(0);
    }
  }

  // output
  std::cout << "Yes" << '\n';
}


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

int main(void){
  int A,B;
  char op;

  scanf("%d %c %d",&A,&op,&B);

  if(op=='+')
    printf("%d\n",A+B);

  else if(op=='-')
    printf("%d\n",A-B);

  else
    printf("error: Input A op B, op is + or -\n");

  return 0;
}


Measured memory_bytes: 128
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

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

int x; 

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin>>x;
	x -= 400;
	cout<<(8 - x / 200)<<endl;

	return 0;
}

Measured memory_bytes: 3544
n, m = map(int,input().split())
xs = list(map(int,input().split()))
ls=[]
before=1000000
for x in sorted(xs):
    if before != 1000000:
        ls.append(abs(x-before))
    before = x
ls2 = sorted(ls,reverse=True)
print(sum(ls2[n-1:]))

Measured memory_bytes: 14088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n,m;cin>>n>>m;
    vll p(n),q(n),r(n),s(n);
    ll x,y,z;
    rep(i,n){
        cin>>x>>y>>z;
        p[i]=x+y+z;
        q[i]=-x+y+z;
        r[i]=x-y+z;
        s[i]=x+y-z;
    }
    sort(all(p));
    sort(all(q));
    sort(all(r));
    sort(all(s));
    ll ans=0;ll front=0;ll back=0;
    rep(i,m){
        front+=p[i];
        back+=p[n-1-i];
    }
    ans=max(ans,max(abs(front),abs(back)));
    front=0;back=0;
    rep(i,m){
        front+=q[i];
        back+=q[n-1-i];
    }
    ans=max(ans,max(abs(front),abs(back)));
    front=0;back=0;
    rep(i,m){
        front+=r[i];
        back+=r[n-1-i];
    }
    ans=max(ans,max(abs(front),abs(back)));
    front=0;back=0;
    rep(i,m){
        front+=s[i];
        back+=s[n-1-i];
    }
    ans=max(ans,max(abs(front),abs(back)));
    cout<<ans<<endl;
}

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

const int MAXM = 1010;
const int INF = 1200010;

int A[MAXM], B[MAXM], C[MAXM];
int dp[1 << 12];

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

	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		for(int j = 0; j < B[i]; j++) {
			int c;
			cin >> c;
			C[i] ^= 1 << (c - 1);
		}
	}

	for(int i = 1; i < (1 << N); i++) dp[i] = INF;
	for(int i = 0; i < M; i++) for(int j = 0; j < (1 << N); j++) if(j & C[i]) dp[j] = min(dp[j], dp[j ^ (j & C[i])] + A[i]);
	
	cout << (dp[(1 << N) - 1] == INF ? -1 : dp[(1 << N) - 1]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	cout << (1000 - n % 1000) % 1000;
	return 0;
}

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

int main() {
	int n,m;
	cin>>n>>m;
	
	
	int k=0;
	for(int i=0;i<m;i++){
		int a=0;
		cin>>a;
		k+=a;
	}
	
	if(k>n)cout<<-1<<endl;
	else cout<<n-k<<endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m),n){
		vvi in(n,vi(n));
		vvi pic(m,vi(m));
		rep(i,n)rep(j,n)scanf("%d",&in[i][j]);
		rep(i,m)rep(j,m)scanf("%d",&pic[i][j]);
		pii out(inf,inf);
		rep(e,4){
			rep(i,n-m+1)rep(j,n-m+1){
				pii t(inf,inf);
				rep(k,m)rep(l,m)
					if(pic[k][l]!=-1&&in[i+k][j+l]!=pic[k][l])goto en;
					else if(pic[k][l]!=-1)t=min(t,pii(i+k,j+l));
				out=min(out,t);
				goto end;
				en:;
			}
			end:;
			vvi tmp=pic;
			rep(i,m)rep(j,m)pic[i][j]=tmp[j][m-i-1];
		}
		if(out.first==inf)cout<<"NA"<<endl;
		else cout<<out.second+1<<" "<<out.first+1<<endl;
	}
}

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

int main() {
	string s, t;
	while ( cin >> s >> t ) {
		int ss = s.size(), ts = t.size();
		
		int lcs[ ss+5 ][ ts+5 ]; memset( lcs, 0, sizeof (lcs) );
		
		for (int i = 1; i <= ss; ++i) {
			for (int j = 1; j <= ts; ++j) {
				if ( s[ i-1 ] == t[ j-1 ] ) {
					lcs[i][j] = lcs[ i-1 ][ j-1 ] + 1;
				}
				else {
					lcs[i][j] = max( lcs[ i-1 ][j], lcs[i][ j-1 ] );
				}
//				cout << ' ' << lcs[i][j];
			}
//			cout << '\n';
		}
		
		stack<char> seq;
		
		while ( ss != 0 or ts != 0 ) {
			if ( ss != 0 and ( ts == 0 or lcs[ ss-1 ][ts] == lcs[ss][ts] ) ) ss-- ;
			else if ( ts != 0 and ( ss == 0 or lcs[ss][ ts-1 ] == lcs[ss][ts] ) ) ts-- ;
			else {
				seq.push( s[ ss-1 ] );
				ss-- ; ts-- ;
			}
		}
		
		while ( !seq.empty() ) {
			cout << seq.top();
			seq.pop();
		}
		
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 35584
import java.math.BigInteger;
import java.util.Scanner;

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

                int N = scan.nextInt();

                BigInteger[] A = new BigInteger[N];
                BigInteger[] Asum = new BigInteger[N];

                for (int i = 0; i < N; i++) {
                	 long temp = scan.nextLong();
                	 A[i] = BigInteger.valueOf(temp);
                }

                Asum[N-1] = A[N-1];

                for (int i = N-2; i >= 0; i--) {
                	Asum[i] = Asum[i+1].add(A[i]);
                }

                BigInteger sum = BigInteger.valueOf(0);

                for (int i = 0; i < N -1; i++) {
                	sum = sum.add(A[i].multiply(Asum[i+1]));
                	sum = sum.mod(BigInteger.valueOf(1000000007));
                }

                System.out.println(sum.intValue());

                scan.close();

        }

}

Measured memory_bytes: 88692
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sanket Makani
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader sc, PrintWriter w) {

            int ans = 0;
            ans = 10 * ans + sc.nextInt();
            ans = 10 * ans + sc.nextInt();
            ans = 10 * ans + sc.nextInt();

            if (ans % 4 == 0)
                w.println("YES");
            else
                w.println("NO");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pi pair <ll,ll>
#define vi vector <ll>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>       //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/


 
int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll i,j,m,t,l=0,x,prev=0,max1=0,flag=0,cnt=0,y,min1,q,sum=0,r,n,k,p,flag2=0,ind=0,b;
    cin>>n>>k;
    ll a[n];
    ll dp[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    //dp[1]=abs(a[1]-a[0]);
    for(i=0;i<n;i++){
        for(j=i+1;j<=i+k&&j<n;j++){
            dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
        }
    }
    cout<<dp[n-1];
    
  
    
    
 
    return 0;
}

Measured memory_bytes: 1792
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

# last4 の文字列
def no_agc_is(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            # swap
            t[i-1], t[i] = t[i], t[i-1]
        # 4charでできた文字列中にAGCがあればfalse
        if "".join(t).count("AGC") >= 1:
            return False
    return True

# 0, 1, 2, 3
memo = [{} for i in range(N+1)]
# memo[0] = {}
# memo[0] = {"TTT": 4}とか
# memo[1]
def dfs(cur, last3):
    # cur, last3 = q.pop()
    # 同じやつあったらメモした奴呼び出し
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in "ACGT":
        if no_agc_is(last3 + c):
            ret = (ret + dfs(cur + 1, (last3 + c)[1:])) % mod
    memo[cur][last3] = ret
    return ret
print(dfs(0, "TTT"))

Measured memory_bytes: 5952
#include <functional>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;

const int INF = 100000000;

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
};

int main()
{
    int n;
    cin >> n;
    int p[200002], q[200002];
    SegmentTree<int> sego(n, [](int a, int b){return min(a, b);}, INF);
    SegmentTree<int> sege(n, [](int a, int b){return min(a, b);}, INF);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
        if(i % 2) sego.set(i, p[i]);
        else sege.set(i, p[i]);
        q[p[i]] = i;
    }
    sego.build();
    sege.build();
    priority_queue<int, vector<int>, greater<int>> que;
    que.push(sege.query(0, n));
    set<int> st;
    st.insert(-1);
    st.insert(n);
    while(que.size()){
        int u = que.top();
        que.pop();
        auto itr = st.lower_bound(q[u]);
        int r = *itr;
        itr--;
        int l = *itr;
        int v;
        if(q[u] % 2){
            v = sege.query(q[u], r);
            if(q[u] != l + 1) que.push(sego.query(l + 1, q[u]));
            if(q[v] != q[u] + 1) que.push(sege.query(q[u] + 1, q[v]));
            if(r != q[v] + 1) que.push(sego.query(q[v] + 1, r));
        }
        else{
            v = sego.query(q[u], r);
            if(q[u] != l + 1) que.push(sege.query(l + 1, q[u]));
            if(q[v] != q[u] + 1) que.push(sego.query(q[u] + 1, q[v]));
            if(r != q[v] + 1) que.push(sege.query(q[v] + 1, r));
        }
        cout << u + 1 << " " << v + 1 << " ";
        st.insert(q[u]);
        st.insert(q[v]);
    }
    cout << endl;
}

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

int main() {
  char xx;
  cin >> xx;
  string abc;
  abc = "abcdefghijklmnopqrstuvwxyz";
  rep(i, 26) {
    if (xx == abc.at(i)) {
      cout << abc.at(i + 1) << endl;
    }
  }
}

      
      

Measured memory_bytes: 256
import sys
from collections import Counter
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ct = Counter(a_ls)
_max = max(a_ls)
_min = min(a_ls)
best = 0
for i in range(_min, _max + 1):
    best = max(ct[i] + ct[i+1] + ct[i-1], best)
print(best)

Measured memory_bytes: 14492
n = gets.to_i
nums = gets.split.map(&:to_i)
q = gets.to_i
queries = []
q.times { queries << gets.split.map(&:to_i) }
sum = nums.sum
hash = Hash.new(0)
nums.each do |num|
  hash[num] += 1
end
queries.each do |a, b|
  tmp = hash[a]
  sum -= a * tmp
  hash[a] = 0
  hash[b] += tmp
  sum += b * tmp
  puts sum
end


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

long long two[400005];
long long mod = 1000000007;
int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n;
	cin >> n;
	
	two[0] = 1;
	for(int i = 1;i < 400000;i++){
		two[i] = two[i-1] * 2LL;
		two[i] %= mod;
	}
	
	long long arr[n];
	for(int i = 0;i < n;i++) cin >> arr[i];
	sort(arr,arr+n);
	reverse(arr,arr+n);
	
	long long base = two[n-1];
	
	long long ans = 0;
	for(int i = 0;i < n;i++){
		ans += base * arr[i];
		ans %= mod;
		if(n >= 2) base += two[n-2];
		base %= mod;
	}
	
	ans *= two[n];
	ans %= mod;
	
	cout << ans;
}


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

void Small_Ink( int a[14][14], int x, int y );
void Middle_Ink( int a[14][14], int x, int y );
void Large_Ink( int a[14][14], int x, int y );

int main()
{
    int x, y, size;
    char p;

    //本来は10*10だが、大きい配列を確保して、はみ出したところを無視すればよい
    int paper[14][14] = {};         //0で初期化

    while( cin >> x >> p >> y >> p >> size )
    {
        if( size == 1 )
            Small_Ink( paper, x + 2, y + 2 );
        else if( size == 2 )
            Middle_Ink( paper, x + 2, y + 2 );
        else
            Large_Ink( paper, x + 2, y + 2 );
    }

    int cnt = 0, max = 0;
    for( int i = 2; i < 12; i++ )
    {
        for( int j = 2; j < 12; j++ )
        {
            if( max < paper[i][j] )
                max = paper[i][j];
            if( paper[i][j] == 0 )
                cnt++;
        }
    }

    cout << cnt << endl << max << endl;

    return 0;
}

void Small_Ink( int a[14][14], int x, int y )
{
    a[x][y]++;
    a[x-1][y]++;
    a[x+1][y]++;
    a[x][y-1]++;
    a[x][y+1]++;
}

void Middle_Ink( int a[14][14], int x, int y )
{
    Small_Ink( a, x, y );
    a[x-1][y-1]++;
    a[x-1][y+1]++;
    a[x+1][y-1]++;
    a[x+1][y+1]++;
}

void Large_Ink( int a[14][14], int x, int y )
{
    Middle_Ink( a, x, y );
    a[x-2][y]++;
    a[x+2][y]++;
    a[x][y-2]++;
    a[x][y+2]++;
}


Measured memory_bytes: 3104
// C - Alchemist
// https://atcoder.jp/contests/abc138/tasks/abc138_c
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w;
  long double ans = 0, count = 0;
  string s, t;
  cin >> n;
  vi v(n);
  rep(i, 0, n)
  {
    cin >> v[i];
  }
  SORT(v);
  ans = v[0];
  rep(i, 1, n)
  {
    ans += v[i];
    ans /= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
const ll BIGMOD = 1e9 + 7;
using namespace std;

int main() {
  ll n, k;
  cin >> n >> k;

  ll mod = abs(n % k);
  ll mins = abs(mod - k);
  cout << min(mod, mins) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 3005;
int cache[mxN][mxN];
int dir[mxN][mxN];
string s,t;
int n,m;
string anslcs = "";
int dp(int i,int j){
	if(i>=n || j>=m)
		return 0;
	int &ans = cache[i][j];
	if(ans!=-1)
		return cache[i][j];
	if(s[i]==t[j]){
		dir[i][j] = 2;
		return ans = 1 + dp(i+1,j+1);
	}
	else{
		int case1 =  dp(i+1,j);
		int case2 = dp(i,j+1);
		if(case1>case2){
			dir[i][j] = 1;
		}
		else
			dir[i][j] = 0;
		return ans = max(case1,case2);
	}
}
void solve(){
	cin>>s>>t;
	n = s.length();
	m = t.length();
	memset(cache,-1,sizeof(cache));
	int ans = dp(0,0);
	string lcs = "";
	int i = 0;
	int j = 0;
	while(lcs.length()!=ans){
		int d = dir[i][j];
		if(d==2){
			lcs+=s[i];
			i++,j++;
		}
		else if(d==1){
			i++;
		}
		else 
			j++;
	}
	cout<<lcs<<'\n';
}

int main() {	
	// IOS
	ll T;
	// cin>>T;
	
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 74572
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    out.println(N * N * N);
  }
}

Measured memory_bytes: 21204
#include <cstdio>
typedef unsigned long long int ll;

bool isfree[50][31];
ll dp[50][31];

ll getstat(int d,int n){
  ll r=0;
  for(int i=0; i<n; i++)
    if(isfree[i][d])
      r |= dp[i][d-1];
  return r;
}

int main(){
  int n;
  while(scanf("%d",&n),n){
    for(int i=0; i<n; i++)
      for(int d=0; d<=30; d++)
	isfree[i][d]=false;

    for(int i=0; i<n; i++){
      int m;
      scanf("%d",&m);
      for(int j=0; j<m; j++){
	int d;
	scanf("%d",&d);
	isfree[i][d]=true;
      }
    }

    for(int i=0; i<n; i++)
	dp[i][0] = 1ULL<<i;

    for(int d=1; d<=30; d++){
      ll stat=getstat(d,n);
      for(int i=0; i<n; i++)
	if(isfree[i][d])
	  dp[i][d] = stat;
	else
	  dp[i][d] = dp[i][d-1];
    }

    int ans=-1;
    for(int d=1; d<=30; d++){
      for(int i=0; i<n; i++){
	if(dp[i][d]==(1ULL<<n)-1){
	  ans=d;
	  goto hoge;
	}
      }
    }
  hoge: printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long maximum;
long long mod = 1000000007;
const int INF = 1001001001;
vector<vector<int>> dp;

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int dx = sx,dy = sy;
  while(dy != ty){
    cout << 'U';
    dy++;
  }
  while(dx != tx){
    cout << 'R';
    dx++;
  }
  while(dy != sy){
    cout <<'D';
    dy--;
  }
  while(dx != sx){
    cout << 'L';
    dx--;
  }
  cout << 'L';
  dx--;
    while(dy != ty+1){
    cout << 'U';
    dy++;
  }
  while(dx != tx){
    cout << 'R';
    dx++;
  }
  cout << "DR";
  dx++; dy--;
  while(dy != sy-1){
    cout <<'D';
    dy--;
  }
  while(dx != sx){
    cout << 'L';
    dx--;
  }
  cout << 'U';
}


Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

ll dist(ll a,ll b)
{
    return ((abs(a-b))*(abs(a-b)));
}

int main()
{
    vector<ll> sq;
    rep(i,0,1000)
    {
        sq.pb((i*i));
    }
    ll n,d,a[11][11],i,j,k,ans=0;
    cin>>n>>d;
    rep(i,0,n-1)rep(j,0,d-1)cin>>a[i][j];
    rep(i,1,n-1)
    {   
        rep(j,0,i-1)
        {   
            k=0;
            rep(i1,0,d-1)
            {
                k+=dist(a[i][i1],a[j][i1]);
            }
            ll check=0;
            for(auto y:sq)
            {
                if(y==k)
                    check++;
            }
            if(check!=0)ans++;
        }
    }cout<<ans;
    return 0;
}


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


int main(){
    int d;
    cin >> d;
    vector<int> c(26,0);
    for(int i=0;i<26;i++){
        cin >> c[i];
    }

    vector<int> ans;
    for(int i=0;i<d;i++){
        int s_max=0;
        int s_j=0;

        for(int j=0;j<26;j++){
            int s;
            cin >> s;
            if(s>s_max){
                s_max = s;
                s_j = j+1;
            }
        }
        ans.push_back(s_j);
    }

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

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(long long N, long long M, std::vector<std::vector<long long>> A){
    unordered_set<LL> masked_sports;
    VI pos(N, 0);
    LL min_max_count = N;
    while (SZ(masked_sports) < M) {
        unordered_map<LL, LL> counts;
        REP(i, N) {
            while (masked_sports.count(A[i][pos[i]]) > 0) {
                pos[i]++;
            }
            counts[A[i][pos[i]]]++;
        }
        LL max_count = 0, max_count_sport;
        EACH(c, counts) {
            if (max_count < c.second) {
                max_count_sport = c.first;
                max_count = c.second;
            }
        }
        min_max_count = min(min_max_count, max_count);
        masked_sports.insert(max_count_sport);
    }
    cout << min_max_count << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
def coins(a,b,c,x):
    num=0
    for i in range(a+1):
        for w in range(b+1):
            for q in range(c+1):
                if 500*i + 100*w + 50*q == x:
                    num += 1
    return num
  
def main():
  a=int(input())
  b=int(input())
  c=int(input())
  x=int(input())
  print(coins(a,b,c,x))
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    } else {
            cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
/* https://atcoder.jp/contests/abc169/tasks/abc169_a */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;

#define f first
#define s second 
#define forn(i, a) for (int i = 0;i < (a);++i)
#define for1(i, b) for (int i = 1; i <= (b);++i)
#define FORd(i, a) for (int i = (a)- 1;i >= 0;--i)
#define F0Rd(i, a, b) for (int i = (a)- 1;i >= (a);--i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const ll MAX = 1e18;

int main() {
	
	ll A, B;
	cin>>A>>B;
	char c;
	cin>>c;
	int D;
	cin>>D;
	B *= 100;
	B += D;
	ll X = A*B;
	X /= 100;
	cout<<X<<endl;
	return 0;
}


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

int n,m; bitset<400> S[400];
int x[200005], y[200005];
bool no[200005];

int main() {
	scanf("%d%d", &n, &m);
	for (int i=0; i<n; i++) S[i][i] = 1;
	for (int i=0; i<m; i++) scanf("%d%d", &x[i], &y[i]), --x[i], --y[i];
	for (int i=m-1; i>=0; i--) {
		for (int j=0; j<n; j++) {
			if (S[j][x[i]] && S[j][y[i]]) no[j] = 1;
			else if (S[j][x[i]]) S[j][y[i]] = 1;
			else if (S[j][y[i]]) S[j][x[i]] = 1;
		}
	}
	int ans = 0;
	for (int i=0; i<n-1; i++)
		for (int j=i+1; j<n; j++)
			if (!no[i] && !no[j] && !(S[i] & S[j]).count()) {
				++ans;
			}
	printf("%d\n", ans);
	return 0;
}
 

Measured memory_bytes: 1152
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}



int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,x;

      bool flag=false;

      string str;

     cin>>x>>n;


       map<ll,ll>mp;

       for(i=0; i<n; i++)
       {
           cin>>a;

           mp[a]=1;
       }

       r=x;

       while(mp[r])r++;

       l=x;

       while(mp[l])l--;

     sum=abs(x-l);

    if(sum<=abs(r-x))cout<<l<<endl;
    else cout<<r<<endl;



}



Measured memory_bytes: 3664
N = int(input())
T = [list(map(str, input().split())) for _ in range(N)]
X = input()

ans = 0
flag = 0
for t in T:
	if flag == 0:
		pass
	else:
		ans+=int(t[1])
		
	if t[0] == X:
		flag = 1
		
print(ans)

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

#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    char input[9];
    for(int i = 0;i < 9;i++) cin >> input[i];
    cout << input[0] << input[4] << input[8] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////

void solve(){
  ini(X);
  vi v(X + 1000 , 0);
  v[0] = 1;
  for(int i = 0 ; i <= X; i++){
    if(v[i] == 0) continue;
    for(int n = 100; n <= 105 ; n++) v[i + n] = 1;
  }
  out(v[X]);

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    string s; cin >> s;
    rep(i,s.size()){
        if(i>=1){
            if(s[i] == s[i-1]){
                cout << i << " " << i+1 << endl;
                return 0;
            }
        }
        if(i>=2){
            if(s[i] == s[i-2]){
                cout << i-1 << " " << i+1 << endl;
                return 0;
            }
        }
    }
    puts("-1 -1");
}

Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

    if(n == 1){
        cout << 1 << endl;
        return 0;
    }

    sort(a.begin(),a.end());

    vector<int> b(1000001),c(1000001);
    if(a.at(0) != a.at(1)) b.at(a.at(0)) = 1;
    if(a.at(n-1) != a.at(n-2)) b.at(a.at(n-1)) = 1;

    for(int i = 1;i < n-1;i ++){
        if(a.at(i) != a.at(i-1) && a.at(i) != a.at(i+1)) b.at(a.at(i)) = 1;
    }

    for(int i = 0;i < n;i ++){
        c.at(a.at(i)) = 1;
    }

    int ans = 0;

    for(int i = 1;i < 500001;i ++){
        if(c.at(i) == 0) continue;

        for(int j = 2;i * j < 1000001;j ++){
            b.at(i*j) = 0;
        }
    }

    for(int i = 0;i < 1000001;i ++) ans += b.at(i);

    cout << ans << endl;
}

Measured memory_bytes: 20328