akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[213456], uiop[213456];
signed main() {
	int n, k, m, a, b = 0; char d; cin >> d;
	if (d == 'a') { cout << 'b' << endl; }
	if (d == 'b') { cout << 'c' << endl; }
	if (d == 'c') { cout << 'd' << endl; }
	if (d == 'd') { cout << 'e' << endl; }
	if (d == 'e') { cout << 'f' << endl; }
	if (d == 'f') { cout << 'g' << endl; }
	if (d == 'g') { cout << 'h' << endl; }
	if (d == 'h') { cout << 'i' << endl; }
	if (d == 'i') { cout << 'j' << endl; }
	if (d == 'j') { cout << 'k' << endl; }
	if (d == 'k') { cout << 'l' << endl; }
	if (d == 'l') { cout << 'm' << endl; }
	if (d == 'm') { cout << 'n' << endl; }
	if (d == 'n') { cout << 'o' << endl; }
	if (d == 'o') { cout << 'p' << endl; }
	if (d == 'p') { cout << 'q' << endl; }
	if (d == 'q') { cout << 'r' << endl; }
	if (d == 'r') { cout << 's' << endl; }
	if (d == 's') { cout << 't' << endl; }
	if (d == 't') { cout << 'u' << endl; }
	if (d == 'u') { cout << 'v' << endl; }
	if (d == 'v') { cout << 'w' << endl; }
	if (d == 'w') { cout << 'x' << endl; }
	if (d == 'x') { cout << 'y' << endl; }
	if (d == 'y') { cout << 'z' << endl; }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

vi A;
int n, m, q;


void update(int idx){
    // cout << "update "  << idx << endl;
    if (idx < 0) return;
    if (A[idx] < m - 1){
        A[idx]++;
        for(int i=idx;i<n;i++){
            A[i] = A[idx];
        }
        return;
    }else{
        update(idx - 1);
    }
}


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

  vi a(q), b(q), c(q), d(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  rep(i, q){
    a[i]--;b[i]--;
  }

  rep(i, n) A.push_back(0);

  vi end(n, m-1);
  int score_mx = 0;
  while(true){
    int score = 0;
    rep(i, q){
      if ((A[b[i]] - A[a[i]] == c[i])) score += d[i];
    }
    update(n - 1);
    score_mx = max(score, score_mx);
    if (A == end) break;
  }

  cout << score_mx << endl;

  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<sstream>
#define maxn 100050
using namespace std;

  typedef struct yyy
  {
      int x;
      char s[15];
  }yyy;

  char ch[15];
  bool cmp(yyy x,yyy y )
  {
      int i=0,j=0,lx=strlen(x.s),ly=strlen(y.s);
      while(i<lx&&i<ly)
      {
          if (x.s[i]>y.s[i]) return 0;
          else if (x.s[i]<y.s[i]) return 1;
          else i++;
      }
       if (lx>ly) return 0;
       else return 1;
  }

  yyy A[maxn];
  int B[maxn];
  int p,n;
  long long sum[maxn];

  int lowbit(int x){return x&-x;}

  void add(int x,int v)
  {
      while(x<=n)
      {
          sum[x]=(sum[x]+v)%p;
          x+=lowbit(x);
      }
  }

  long long getsum(int x)
  {
      long long Sum=0;
      while(x>0)
      {
          Sum=(Sum+sum[x])%p;
          x-=lowbit(x);
      }
      return Sum;
  }


  void f(int x,int s)
  {
      sprintf(A[x].s,"%d",s);
  }

  int main()
  {
      int a,b;
      int i,x,j;
      while(cin>>a>>b>>p&&a!=0)
      {

      memset(A,0,sizeof(A));
      memset(B,0,sizeof(B));
      memset(sum,0,sizeof(sum));
          n=b-a+2;
           for (i=a;i<=b;i++)
           {
               A[i-a+1].x=i-a+1;
               f(i-a+1,i);
           }

           sort(A+1,A+b-a+2,cmp);
           //for (i=1;i<=b-a+1;i++) cout<<A[i].x<<' '<<A[i].s<<endl;
           for (i=1;i<=b-a+1;i++)
             B[A[i].x]=i;

           for (i=1;i<=b-a+1;i++)
             {
             add(B[i],getsum(B[i]-1)+1);
             // for (j=1;j<=b-a+1;j++) cout<<sum[j]<<' ';
              //cout<<endl;
             }
           long long Sum=getsum(b-a+1);
           cout<<Sum<<endl;

      }




      return 0;
  }

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    string s;
    cin>>s;
    map<char,int> abc;
    rep(i,s.size()) abc[s[i]]++;
    rep(i,26){
        if(abc['a'+i]==0){
            cout<<char('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 512
main(n,a,b,c,x,r,z){
  for(;scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n;){
    scanf("%d",&z);
    for(r=0;n;r++){
      if(r>10000){r=-1;for(;--n;)scanf("%d",&z);;break;}
      if(z==x){if(!(--n))break;scanf("%d",&z);}
      x=(a*x+b)%c;
    }
    printf("%d\n",r);
  }
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }

  ll ans = 0;
  int r = 0;
  ll sum = 0;
  rep(l, 0, N) {
    for (; r < N; r++) {
      if (sum & A[r]) break;
      sum ^= A[r];
    }
    ans += r - l;
    sum ^= A[l];
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 1792
//????¶???????????????????????????¢????????????
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner kb=new Scanner(System.in);
		int n=kb.nextInt();
		
		/*??????????????????*/
		int count[][]=new int[4][13];
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				count[i][j]=0;
			}
		}
		/*???????????§*/

		String mark;
		int nowCard;
		for(int i=0;i<n;i++){//??????????????????
			mark=kb.next();
			switch(mark){
			case "S":nowCard=kb.nextInt();
			count[0][nowCard-1]++;
			continue;
			
			case "H":nowCard=kb.nextInt();
			count[1][nowCard-1]++;continue;
			
			case "C":nowCard=kb.nextInt();
			count[2][nowCard-1]++;continue;
			
			case "D":nowCard=kb.nextInt();
			count[3][nowCard-1]++;continue;
			}
		}

		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				if(count[i][j]==0){//
					switch(i){
					case 0:System.out.printf("S"+" %d\n",j+1);continue;
					case 1:System.out.printf("H"+" %d\n",j+1);continue;
					case 2:System.out.printf("C"+" %d\n",j+1);continue;
					case 3:System.out.printf("D"+" %d\n",j+1);continue;
					}
				}
			}
		}
		kb.close();
	}	
}

Measured memory_bytes: 26284
N,K = map(int,input().split())
a = list(map(int,input().split()))
b = []
dis = N-K+1
for i in range(dis):
  b.append(min(abs(a[i])+abs(a[i]-a[i+K-1]),abs(a[i+K-1])+abs(a[i+K-1]-a[i])))
print(min(b))
    


Measured memory_bytes: 14384
N , X  = (int(i) for i in input().split()) 
L = [int(i) for i in input().split()]
D = 0
if X < L[0]:
  print(1)
elif sum(L) <= X:
  print(N+1)
else:
  for i in range(N):
    D = D + L[i]
    if D > X:
      break
  print(i+1)

Measured memory_bytes: 3064
#!/usr/bin/env python3
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for i, a_i in enumerate(a):
    if i == n - 1:
        if x == a_i:
            x -= a_i
            cnt += 1
    else:
        if x >= a_i:
            x -= a_i
            cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int money1[3]={0},money2[2]={0},sum=0;
	for(int i=0;i<3;i++){
		scanf("%d",&money1[i]);
	}
	for(int i=0;i<2;i++){
		scanf("%d",&money2[i]);
	}
	sort(money1,money1+3);
	sort(money2,money2+2);
	sum=money1[0]+money2[0]-50;
	printf("%d\n",sum);
	return 0;
}

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

const int maxn=2e5+5;

char s[maxn];

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

    cin>>s+1;
    int len=strlen(s+1),sum=0;
    for(int i=1;i<=len;i++) sum+=s[i]-'0';
    if(sum%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3744
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cout << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cout << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int N = in();
	vint a(N);
	rep(i,N) a[i] = in();
	sort(a.begin(), a.end());
	if (a[N-1] - a[0] >= 2) {
		cout << "No" << endl;
		return 0;
	}
	
	int k = a[0];
	int p = 0, q = 0;
	rep(i,N) a[i] == k ? p++ : q++;
	
	if (q == 0) {
		if (k == N - 1 || k <= N / 2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
	}
	else {
		if (p <= k && k <= p + q / 2 - 1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int ls (int);
int n, S[10000];
int main(){
  int q,T[500],i,j,x=0;

  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&S[i]);
  
  scanf("%d",&q);
  for(i = 0; i < q; i++)
    scanf("%d",&T[i]);

  for(i = 0; i < q; i++){
    if(ls(T[i]) == T[i]) x++;
  }

  printf("%d\n",x);

  return 0;
}

int ls(int key){
  int j;
      for(j = 0; j < n; j++){
	if(key == S[j]) return key;
    }
      return 0;
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int h, w;
    cin>>h>>w;
    vector<string> grid(h);
    cin>>grid;
    rep(i, h) rep(j, w) {
        if (grid[i][j] == '#') {
            bool f = false;
            if (i + 1 < h && grid[i + 1][j] == '#') f = true;
            if (i - 1 >= 0 && grid[i - 1][j] == '#') f = true;
            if (j + 1 < w && grid[i][j + 1] == '#') f = true;
            if (j - 1 >= 0 && grid[i][j - 1] == '#') f = true;
            if (!f) {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        A = list(map(int, input().split()))

        dic = {}
        for i, a in enumerate(A):
            dic[a] = i+1

        for i in range(1,N+1):
            print(dic[i], end=' ')


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 62872
//Dragon_warrior7(IITK)
//#pragma GCC optimize("O0") 
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("-ffloat-store")
#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 umap unordered_map
#define uset unordered_set
#define ll long long
//#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
//#define ull unsigned ll
#define cerr cout
#define vll vector<ll>
#define vpll vector<pll> 
#define rub cerr << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{for (int i = 0; i < v.size(); i++)cin>>v[i];}
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll int gcd(ll int a ,ll int b)
{if(b==0) return a;a%=b;return gcd(b,a);}
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
cin>>n>>k;
ll ans=0;
for(ll i=k;i<=n+1;i++)
{
    ll mi=(i*(i-1))/2;
    ll mx=(n*(n+1))/2;
    mx-=((n+1-i)*(n-i))/2;
    mx=max(mi,mx);
    ans+=(mx-mi+1+mod)%mod;
    //deb(mx);
    //deb(mi);
    ans%=mod;
}
cout<<ans;
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3982722#1
struct SegmentTree{
private:
	vector<ll> node;
	int n;
    ll I=inf;//ここに代入

public:
	SegmentTree(){
		int sz=100010;
		n=1;
		//要素数を2のべき乗にする
		while(n<sz) n*=2;
		rep(i,2*n-1) node.push_back(I);//全ての要素をinfで初期化//これは定義される演算における単位元
	}

	//k番目の値をaに変更する
	void update(int k,ll a){
		k+=n-1;
		node[k]=a;
		while(k>0){
			k=(k-1)/2;
			node[k]=min(node[2*k+1],node[2*k+2]);//これは結合則が満たされる任意の演算でok
		}
	}

	//[a,b)の最小値を求める,find(a,b+1)でよぶ
	ll find(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=n;
		if(r<=a || b<=l) return I;
		if(a<=l && r<=b) return node[k];
		else{
			ll vl=find(a,b,2*k+1,l,(l+r)/2);
			ll vr=find(a,b,2*k+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
};

struct edge{int l,r,c;};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<edge> g(m);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--,b--;
		g[i]={a,b,c};
	}
	vector<ll> dp(n,inf);
	dp[0]=0;
	SegmentTree seg;
	seg.update(0,0);
	sort(begin(g),end(g),[&](const edge &a,const edge &b){
		return a.l<b.l;
	});
	rep(i,m){
		int st=g[i].l,en=g[i].r,cost=g[i].c;
		chmin(dp[en],seg.find(st,en)+cost);
		seg.update(en,dp[en]);
	}
	if(dp[n-1]>=inf) cout<<-1<<endl;
	else cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4340
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int K = 0;
int A = 0;
int y = 0;



int main() {
	cin >> K;
	for (int i = 0; i < K; i++) {
		if ((i + 1) % 2 == 0){
			A++;
		}

		else if ((i + 1) % 2 == 1) {
			y++;
		}
	}

	cout << A * y;
	return 0;
}

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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

LL n,i;
cin >> n;

vector <LL> v(n);

for(i=0;i<n;i++) cin >> v[i];

stack <pair <LL,LL> > st;
LL sum = 0,cnt = 0,ans = 0; 

for(i=0;i<n;i++)
	{cnt = 0;
	while((!st.empty()) && st.top().first > v[i])
		{
		cnt += st.top().second;	
		sum -= st.top().first*st.top().second; 
		st.pop();
		}
	cnt ++;
	st.push(MP(v[i],cnt));
	sum = sum + v[i]*cnt;
	ans += sum;
	}

cout << ans << endl;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, k, cnt = 1, to;
  cin >> n >> k;
  vector<int> a(n);
  arep(i, a) cin >> i;

  vector<int> ans, v(n + 1, -1);

  while (v[cnt] == -1) {
    v[cnt] = ans.size();
    ans.push_back(cnt);
    cnt = a[cnt - 1];
  }

  to = ans.size() - v[cnt];
  cnt = v[cnt];

  if (k < cnt)
    cout << ans[k] << '\n';
  else {
    k -= cnt;
    k %= to;
    cout << ans[cnt + k] << '\n';
  }
  return 0;
}

Measured memory_bytes: 8452
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


ll f(ll n) {
	ll ret = 0;
	while (n > 0) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

ll p(ll i) {
	ll a = 1;
	REP(j, i)a *= 10;
	return a;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	cin >> k;
	ll a = 1;
	vl ret;
	REP(i, 15) {
		REP(j, 9) {
			ret.push_back((j + 1)*a + a - 1);
		}
		a *= 10;
	}
	REP(i, ret.size()) {
		int d = log10(ret[i]) + EPS;
		REP(k, d) {

			ll m = ret[i] / p(k) % 10;


			ll prev = ret[i] - p(k);
			if (prev*f(ret[i]) <= ret[i] * f(prev))ret.push_back(prev);


		}
	}

	sort(ALL(ret));
	UNIQUE(ret);


	REP(i, k)cout << ret[i] << endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  string a,b,c;
  cin >> a >> b >> c;

  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


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

typedef struct{
  int x,y;
} point;

void shift_o(point ep, point *line, int m){
  rep(i,m){
    line[i].x -= ep.x;
    line[i].y -= ep.y;
  }
}

void round(point *line, int m){
  rep(i,m){
    point tmp = line[i];
    line[i].x = -(tmp.y);
    line[i].y = tmp.x;
  }
}

bool IsSame(point *base, point *line, int m){
  rep(i,m){
    if(line[i].x != base[i].x || line[i].y != base[i].y)
      return false;
  }
  return true;
}

void CopyLine(const point *original, point *copy, int m){
  while(m-->0){
    *copy++ = *original++;
  }
}

void revline(point *line,int m){ 
  point tmp;
  rep(i,m/2){
    tmp=line[i];
    line[i]=line[m-i-1];
    line[m-i-1]=tmp;
  }
}

void Plus5(){
  rep(i,5){
    putchar('+');
  }
  putchar('\n');
}

int main(){
  for(;;){
    int n;
    scanf("%d",&n);
    if(!n) break;

    int m0;
    point base[10];
    scanf("%d",&m0);
    rep(i,m0){
      scanf("%d %d",&base[i].x,&base[i].y);
    }

    int m[50];
    point line[50][10];
    rep(i,n){
      scanf("%d",&m[i]);
      rep(j,m[i]){
	scanf("%d %d",&line[i][j].x,&line[i][j].y);
      }
    }

    point ep1=base[0] ,ep2=base[m0-1];

    point copy[10];
    CopyLine(base,copy,m0);

    shift_o(ep1,base,m0);
    shift_o(ep2,copy,m0);

    rep(i,n){
      if(m[i]==m0){
	shift_o(line[i][0], line[i], m0);
	if(IsSame(base,line[i],m0)||IsSame(copy,line[i],m0)){
	  printf("%d\n",i+1);
	  continue;
	}
	revline(line[i], m0);
	shift_o(line[i][0], line[i], m0);
	if(IsSame(base,line[i],m0)||IsSame(copy,line[i],m0)){
	  printf("%d\n",i+1);
	  continue;
	}
	revline(line[i], m0);
	shift_o(line[i][0], line[i], m0);
	rep(j,3){
	  round(line[i],m0);
	  if(IsSame(base,line[i],m0)||IsSame(copy,line[i],m0)){
	    printf("%d\n",i+1);
	    break;
	  }
	  revline(line[i], m0);
	  shift_o(line[i][0], line[i], m0);
	  if(IsSame(base,line[i],m0)||IsSame(copy,line[i],m0)){
	    printf("%d\n",i+1);
	    break;
	  }
	}
      }
    }  
    Plus5();
  } 
}

Measured memory_bytes: 1196
while True:
    try: tmp = input()
    except: break

    joi,ioi = 0,0

    for i in range(len(tmp)):
        if tmp[i:i+3]=="JOI":
            joi += 1
        elif tmp[i:i+3]=="IOI":
            ioi += 1
        
    print(joi,ioi,sep="\n")
        


Measured memory_bytes: 5572
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x) 			memset(x, 0, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e6 + 5;
const int MOD=1e9 + 7;



vector<int> find_factors(int f)
{
	int i;
	vector<int> vec;	
	for(i=1;i*i<=f;i++)
	{
		if(f%i==0)
		{
			if(i*i==f)
			{
				vec.pb(i);
			}
			else
			{
				vec.pb(i);
				vec.pb(f/i);
			}
		}
	}
	sort(all(vec));
	return vec;
}

int32_t main()
{
	IOS;
	int T=1;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		int a[n+5];
		unordered_map<int,int> mp;
		rep(i,1,n)
		{
			cin >> a[i];
			mp[a[i]]++;
		}
		int ans = 0;
		rep(i,1,n)
		{
			mp[a[i]]--;
			vi v = find_factors(a[i]);
			int flag = 0;
			for(int x:v)
			{
				if(mp[x]>=1)
				{
					flag = 1;
					break;
				}
			}
			if(flag==0)
				ans++;
			mp[a[i]]++;
		}
		cout << ans;
	}
}



Measured memory_bytes: 33348
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main {

  static long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a%b);
  }

  static long lcm(long t, long ab) {
    return ab / t;
  }

  public static void main(String[] args) throws IOException {
    long a, b, t;
    BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
    String str;
    String[] array = new String[2];
    while ((str = buf.readLine()) != null) {
      array = str.split(" ");
      a = Long.parseLong(array[0]);
      b = Long.parseLong(array[1]);
      t = gcd(a, b);
      System.out.println(t + " " + lcm(t, a*b));
    }
  }
}

Measured memory_bytes: 24476
import java.util.*;

public class Main {

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

    for (int i = 0; i < x; i++) {
      int high = i * 105;
      int low = i * 100;
      if (low <= x && x <= high) {
        System.out.println(1);
        return;
      }
    }

    System.out.println(0);

  }

}


Measured memory_bytes: 23760
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  string a,b,c,ans="NO";
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]) ans="YES"; 
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  ll a;
  string s;
  cin >> a >> s;
  if (a >= 3200) {
    cout << s << endl;
  }else {
    cout << "red" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

const int mod = 1e9 + 7;
const int s = 1e6 + 1;

int32_t main()
{

	//shuru_krte_hai_bina_kisi_bakchodi_ke();
	int n;
	cin>>n;
	int count  = 0;
	int flag = 0;
	while(n--){
		int x,y;
		cin>>x>>y;
		if(x==y){
			count++;
		}else{
			count  = 0;
		}
		if(count>=3){
			flag=1;
		}
	}
	if(flag){
		cout<<"Yes"<<"\n";
	}else{
		cout<<"No"<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 3620
// Problem: E - Coprime
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define elif else if
#define VPII vector <PII>
#define y2 y1919810
typedef pair <int, int> PII;
typedef vector <int> VI;
//#define int long long
#define all(x) x.begin(),  x.end()
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
#define RESET(x) memset((x), 0, sizeof(x))
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
int n;
const int N = 1000010;
int a[N];
int occ[N];
void solve() {
  cin >> n;
  repn(i, n) cin >> a[i];
  bool pwg = true;
  repn(c, n) {
    int x = a[c];
    for (int i = 2; i * i <= x; i++) {
      if (x % i == 0) {
        occ[i]++;
        if (occ[i] > 1) pwg = false;
        while (x % i == 0) x /= i;
      }
    }
    if (x != 1) occ[x]++;
    if (occ[x] > 1) pwg = false;
  }
  if (pwg) {
    cout << "pairwise coprime" << endl;
    return;
  }
  for (int i = 1; i <= 1000000; i++) if (occ[i] == n) {
    cout << "not coprime" << endl;
    return;
  }
  cout << "setwise coprime" << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  int T = 1;
  // cin >> T;
  while (T--) 
    solve();
  return 0;
}


Measured memory_bytes: 11212
import itertools
import numpy as np
N = int(input())
S = input()

ind_table = [[] for _ in range(10)]
for i in range(N):
	ind_table[int(S[i])].append(i)

ind_table = np.array(ind_table)


num_list = ['1','2','3','4','5','6','7','8','9','0']

ans = 0
for nums in itertools.product(num_list,num_list,num_list):
	tmp = 0
	cond = 1
	for i in range(3):
		num = int(nums[i])
		L = len(ind_table[num])
		if L == 0:
			cond = 0
			break

		ind = np.searchsorted(ind_table[num], tmp)
		if ind == L:
			cond = 0
			break
		else:
			tmp = ind_table[num][ind] + 1

	if cond:
		ans += 1


print(ans)

Measured memory_bytes: 15472
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

  static int n, ans;
  static long k;
  static List<Integer> a, step;

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

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    k = Long.parseLong(in[1]);

    in = br.readLine().split(" ");
    a = Arrays.stream(in).map(Integer::parseInt).collect(Collectors.toList());

    br.close();


    step = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      step.add(0);
    }

    int loop = 1, city = a.get(0);

    while (step.get(city-1) == 0 && city != 1) {
      step.set(city - 1, loop++);
      city = a.get(city - 1);
    }

    int period = loop - step.get(city-1);

    if (k > step.get(city-1)) {
      k = (k - step.get(city-1)) % period + step.get(city-1);
    }

    city = 1;

    for (int i = 0; i < k; i++) {
      city = a.get(city - 1);
    }

    out.println(city);

    out.flush();
  }
}


Measured memory_bytes: 63372
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int, int> ii;

// Good approach: If the constraint is stricter, we should go for something like BFS 0 - 1. 
// -> Construct graph with weight 0 / 1. 
int k, d[100005]; 
 
deque<int> dq; 

signed main()
{
	cin >> k; 
	for(int i = 0; i <= k; i++) {
		d[i] = 1e9; 
 	}
	dq.push_front(1); d[1] = 1; 
	while(!dq.empty()) {
		int u = dq.front(); dq.pop_front(); 
		if(!u) {
			cout << d[u]; 
			return 0; 
		}
		if(d[u * 10 % k] > d[u]) {
			d[u * 10 % k] = d[u]; 
			dq.push_front(u * 10 % k); 
		}
		if(d[(u + 1) % k] > d[u] + 1) {
			d[(u + 1) % k] = d[u] + 1;  
			dq.pb((u + 1) % k); 
		}
	}
}


Measured memory_bytes: 4772
n = int(input())
d = {}
for _ in range(n):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
maximum = 0
s_list = None
for s, t in d.items():
  if maximum < t:
    maximum = t
    s_list = [s]
  elif maximum == t:
    s_list.append(s)
s_list.sort()
for s in s_list:
  print(s)

Measured memory_bytes: 32096
#include <bits/stdc++.h>
#include <atcoder/maxflow>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

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

char LEFT = '>';
char RIGHT = '<';
char TOP = 'v';
char BOTTOM = '^';

int main() {
  
  int N, M;
  cin >> N >> M;
  vector<string> S(N);
  rep(i,N) cin >> S[i];

  mf_graph<int> graph(M * N + 2);

  rep(i,N) rep(j,M) {
    if (S[i][j] == '#') continue;
    if ((i + j) % 2 == 0) {
      graph.add_edge(0, i * M + j + 1, 1);
      rep(k,4) {
        int y = i + dy[k];
        int x = j + dx[k];
        if (y < 0 || y >= N || x < 0 || x >= M) continue;
        graph.add_edge(i * M + j + 1, y * M + x + 1, 1);
      }
    } else {
      graph.add_edge(i * M + j + 1, M * N + 1, 1);
    }
  }

  cout << graph.flow(0, M * N + 1) << endl;
  vector<mf_graph<int>::edge> edges = graph.edges();

  for (auto e: edges) {
    if (e.flow == 0) continue;
    if (e.from == 0 || e.to == M * N + 1) continue;
    e.from--; e.to--;
    int i = e.from / M, j = e.from % M;
    int y = e.to / M, x = e.to % M;
    if (j == x - 1) {
      S[i][j] = LEFT;
      S[y][x] = RIGHT;
    } else if (j == x + 1) {
      S[i][j] = RIGHT;
      S[y][x] = LEFT;
    } else if (i == y - 1) {
      S[i][j] = TOP;
      S[y][x] = BOTTOM;
    } else {
      S[i][j] = BOTTOM;
      S[y][x] = TOP;
    }
  }

  rep(i,N) cout << S[i] << endl;

  return 0;
}

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  
  bool res = true;
  for (int i = a; i < b + 1; i++) {
    if (i % k == 0) {
      res = false;
      cout << "OK" << endl;
      break;
    }
  }
  
  if (res)
    cout << "NG" << endl;

  return 0;
}
    

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


int main() {
	int N, counter = 0;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A.at(i);

	bool repTF = true;
	while(repTF){
		for (int i = 0; i < N ; ++i) {
			if (A.at(i) % 2 != 0) {
				cout << counter << endl;
				return 0;
			}
		}
		for (int i = 0; i < N ; ++i) {
			A.at(i) /= 2;
		}
		++counter;
	}

}


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

int main(void) {
  int k, n;
  cin >> n >> k;
  vector<int> ps(n);
  for (int &p : ps) cin >> p;

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

  int result = 0;
  for (int i = 0; i < k; i++) {
    result += ps[i];
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    long long H;
    cin >> H;
    //ong double logH;
    
    //logH = log10(H)/log10(2);

    long long N,Htmp;
    Htmp=H;
    N=0;
    while(Htmp>1){
        Htmp /=2;
        N++;
    }


    long long ans,itmp;
    long double tmp;
    ans = (long long) (pow(2.0,(long double) (N+1.0) )-1.0);

    cout << ans << endl;

    return 0;
}

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

namespace ConsoleApp1
{

    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var n = (int)input[0];
            var m = (int)input[1];
            var k = input[2];

            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var b = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var cuma = new long[n + 1];
            var cumb = new long[m + 1];
            int maxa = n;
            int maxb = m;

            int res = 0;

            for (int i = 0; i < n; i++)
            {
                cuma[i + 1] = cuma[i] + a[i];
                if (cuma[i + 1] > k)
                {
                    maxa = i;
                    break;
                }

            }

            for (int i = 0; i < m; i++)
            {
                cumb[i + 1] = cumb[i] + b[i];
                if (cumb[i + 1] > k)
                {
                    maxb = i;
                    break;
                }

            }

            int j = maxb;
            for (int i = 0; i <= maxa; i++)
            {
                while (true)
                {
                    if (cuma[i] + cumb[j] > k)
                        j--;
                    else
                    {
                        res = Math.Max(res, i + j);
                        break;
                    }
                }
            }

            Console.WriteLine(res);

        }

    }
}



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

int main(){
string S, T;
cin >> S >> T; 
sort(S.begin(), S.end());
sort(T.begin(), T.end());
reverse(T.begin(), T.end());
if(S < T) cout << "Yes" << endl; 
else cout << "No" << endl; 
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0144

"""
import sys
from sys import stdin
input = stdin.readline
from enum import Enum


class Graph(object):
    """ single source shortest path """
    class Status(Enum):
        """ ?????????????¨??????¶??? """
        white = 1  # ????¨????
        gray = 2  # ?¨???????
        black = 3  #?¨???????

    def __init__(self, n, data):
        self.num_of_nodes = n+1
        self.color = [Graph.Status.white] * self.num_of_nodes  # ????????????????¨??????¶???
        self.M = [[float('inf')] * self.num_of_nodes for _ in range(self.num_of_nodes)]
        for i in range(self.num_of_nodes):
            self.M[i][i] = 0
        self._make_matrix(data)  # data????????????????????£??\??????(?????\?¶???¨???????????????????????§????????????)
        self.d = [float('inf')] * self.num_of_nodes  # ?§???????????????????(?????????)
        self.p = [-1] * self.num_of_nodes  # ????????????????????????????¨?????????????????????????

    def _make_matrix(self, data):
        for d in data:
            r = d[0]
            for t in d[2:]:
                self.M[r][t] = 1

    def dijkstra(self, start):
        self.d[start] = 0
        self.p[start] = -1
        while True:
            mincost = float('inf')
            # ??\??????????????§??????????????¨?????????????????????u???????????????
            for i in range(len(self.d)):
                if self.color[i] != Graph.Status.black and self.d[i] < mincost:  # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
                    mincost = self.d[i]
                    u = i  # u??????????????????ID
            if mincost == float('inf'):
                break
            self.color[u] = Graph.Status.black  # ?????????u???S????±???????????????´???
            for v in range(len(self.d)):
                if self.color[v] != Graph.Status.black and self.M[u][v] != float('inf'):
                    # v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
                    if self.d[u] + self.M[u][v] < self.d[v]:
                        self.d[v] = self.d[u] + self.M[u][v]
                        self.p[v] = u
                        self.color[v] = Graph.Status.gray

    def warshallFloyd(self):
        V = self.num_of_nodes
        for k in range(V):
            for i in range(V):
                for j in range(V):
                    self.M[i][j] = min(self.M[i][j], self.M[i][k] + self.M[k][j])



def main(args):
    n = int(input())
    network = []
    for _ in range(n):
        network.append([int(x) for x in input().split()])

    packets = []
    p = int(input())
    for _ in range(p):
        packets.append([int(x) for x in input().split()])

    g = Graph(n, network)
    g.warshallFloyd()

    for s, d, v in packets:
        if g.M[s][d] < v:
            print(g.M[s][d]+1)
        else:
            print('NA')



if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8556
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define Max(_A,_B) ((_A)>(_B)?(_A):(_B))
#define Swap(_A,_B) ((_A)^=(_B)^=(_A)^=(_B))
using namespace std;
/*
其中，f[k]表示递推到第i位的最大值。
那么，f[k]显然是可以从f[k-1]递推来的。
这时候只要考虑i|j==k的值。
枚举k的子集，求最大值。
这样做是O(松松松)的。
考虑优化。
我们可以发现，对于k的每一个子集，它的子集的最大值是已经求过的。
那么我们只需要考虑枚举每一个k子集的一部分，可以考虑每一次把它反与上一个2^l，并求Max和次Max。
这样有解，复杂度O(n*2^n)。 
*/
//mx[i][0]表示最大值，mx[i][1]表示次大值。 
int f[1<<18],n,a[1<<18];
int nw,mxx,lmxx,sa,sb,st;
struct data{
    int v;
    int nm;
    bool operator ==(const data &x)const{
        return this->v==x.v&&this->nm==x.nm;
    }
}lst[40],mx[1<<18][2];
inline bool cmp(const data &x,const data &y){
    return x.v>y.v;
}
//处理第k个数，它的最大值和次大值。 
int wrk(int k){
    nw=0,mxx=0,lmxx=0,sa=-1,sb=-1,st=0;
    lst[++st]=(data){a[k],k};
    for(int i=0;(1<<i)<=k;++i){
        if((k>>i)&1){
            nw=k^(1<<i);
        }else{
            continue;
        }
        lst[++st]=mx[nw][0];
        lst[++st]=mx[nw][1];
    }
    sort(lst+1,lst+1+st,cmp);
    unique(lst+1,lst+1+st);
    mx[k][0]=lst[1],mx[k][1]=lst[2];
    return mx[k][0].v+mx[k][1].v;
}
void init(){
    scanf("%d",&n);
    const int MAX=1<<n;
    for(int i=0;i<MAX;++i){
        scanf("%d",&a[i]);
    }
    f[0]=0,mx[0][0].v=a[0],mx[0][1].v=0,mx[0][0].nm=0,mx[0][1].nm=-1;
    for(int k=1;k<MAX;++k){
        f[k]=wrk(k);
        f[k]=Max(f[k],f[k-1]);
        printf("%d\n",f[k]);
    }
}
int main(){
    init();
    return 0;
} 

Measured memory_bytes: 9216