akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;
  if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,m,i;

  scanf("%d",&n);

  for(i=1; i<=n; i++){
    if(i%3 == 0)
      printf(" %d",i);

    m = i;
    
    while(m>0){
      if(i%3 == 0 && m%10 == 3)
	break;
      if(m%10 == 3){
	printf(" %d",i);
        break;
      }
      m/=10;
    }
  }
  printf("\n");
  return 0;
  
}
      


Measured memory_bytes: 2124
#include "bits/stdc++.h"
using namespace std;
#define maxn 301
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair

const int mod = 1000000000 + 7;
void add(int &x, int y){
    x += y;
    if(x>=mod) x-=mod;
}

int dp[maxn][maxn][maxn], bad[maxn][maxn][maxn];

void solve(){
    int n, m;
    cin >> n >> m;
    while(m--){
        int l, r, x;
        cin >> l >> r >> x;
        if(x==1){
            for(int a=l; a<r; ++a){
                for(int b=0; b<r; ++b){
                    bad[a][b][r] = 1;
                    bad[b][a][r] = 1;
                    bad[a][r][b] = 1;
                    bad[b][r][a] = 1;
                    bad[r][a][b] = 1;
                    bad[r][b][a] = 1;
                }
            }
        }
        if(x==2){
            for(int a=l; a<r; ++a){
                for(int b=l; b<r; ++b){
                    bad[a][b][r] = 1;
                    bad[b][a][r] = 1;
                    bad[a][r][b] = 1;
                    bad[b][r][a] = 1;
                    bad[r][a][b] = 1;
                    bad[r][b][a] = 1;
                }
            }
            for(int a=0; a<l; ++a){
                for(int b=0; b<l; ++b){
                    bad[a][b][r] = 1;
                    bad[b][a][r] = 1;
                    bad[a][r][b] = 1;
                    bad[b][r][a] = 1;
                    bad[r][a][b] = 1;
                    bad[r][b][a] = 1;
                }
            }
        }
        if(x==3){
            for(int a=0; a<l; ++a){
                for(int b=0; b<r; ++b){
                    bad[a][b][r] = 1;
                    bad[b][a][r] = 1;
                    bad[a][r][b] = 1;
                    bad[b][r][a] = 1;
                    bad[r][a][b] = 1;
                    bad[r][b][a] = 1;
                }
            }
        }
    }
    //dp
    dp[0][0][0] = 1;
    int ans = 0;
    rep(r, n+1){
        rep(g, n+1){
            rep(b, n+1){
                int k = max(r, max(g, b));
                if(k==n){
                    add(ans, dp[r][g][b]);
                }else{
                    if(!bad[k+1][g][b]) add(dp[k+1][g][b], dp[r][g][b]);
                    if(!bad[r][k+1][b]) add(dp[r][k+1][b], dp[r][g][b]);
                    if(!bad[r][g][k+1]) add(dp[r][g][k+1], dp[r][g][b]);
                }
            }
        }
    }
    cout << ans;
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);
    solve();
}

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

#define INF 1000000009

int N,M,R;
int D[300][300];
int r[10];
int dp[200][400];

int F(int n,int bit)
{
    if(bit == (1 << R) - 1)return 0;
    if(dp[n][bit] != -1)return dp[n][bit];

    int nn = r[n];

    int res = INF;

    for(int i = 0; i < R; i++)
    {
        if((bit & (1 << i)) == 0)res = min(F(i,bit | (1 << i)) + D[nn][r[i]],res);
    }

    return dp[n][bit] = res;
}

int main()
{
    memset(D,INF,sizeof(D));
    memset(dp,-1,sizeof(dp));
    scanf("%d%d%d",&N,&M,&R);
    for(int i = 1; i <= N; i++)D[i][i] = 0;

    for(int i = 0; i < R; i++)scanf("%d",r + i);

    for(int i = 0; i < M; i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        D[a][b] = D[b][a] = c;
    }

    for(int k = 1; k <= N; k++)
        for(int j = 1; j <= N; j++)
            for(int i = 1; i <= N; i++)
                D[i][j] = min(D[i][j],D[i][k] + D[k][j]);

    int res = INF;

    for(int i = 0; i < R; i++)res = min(res,F(i,(1 << i)));

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

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
struct Node{
	int l,r;
}a[N];
bool cmp(Node a,Node b){
	return a.r<b.r;
}
int main (){
	int n;scanf ("%d",&n);
	for (int i=1;i<=n;i++) {
		int x,l;scanf ("%d%d",&x,&l);
		a[i]=(Node){x-l,x+l};
	}
	sort(a+1,a+n+1,cmp);int lst=-1e9,ans=0;
	for (int i=1;i<=n;i++)
		if (lst<=a[i].l) lst=a[i].r,ans++;
	printf ("%d",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
namespace ZDY{
#define ll long long
#define Fur(i,x,y) for(int i=x;i<=y;i++)
#define Fdr(i,x,y) for(int i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(ll i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 999999999
}
namespace FAST{
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
namespace fib{char b[300000]= {},*f=b;}
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
inline void in(int &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}struct foce{~foce(){pob;fflush(stdout);}} _foce;namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}inline void outn(ll x){out(x);pc('\n');}
inline void out(int x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}inline void outn(int x){out(x);pc('\n');}
inline char sc(){char c=gc;while(!(('A'<=c&&c<='Z')||('a'<=c&&c<='z')))c=gc;return c;}
}using namespace FAST;using namespace ZDY;using namespace std;
#define N 1001
char ch[N];
int main(){
	ll k,d;
	scanf("%s%lld",ch,&d);
	k=strlen(ch);
	for(ll i=0;i<k;i+=d)pc(ch[i]);
}

Measured memory_bytes: 256
//<--sbhmshss-->//

#include <bits/stdc++.h>
#include <iostream>
#define FASTIO std::ios::sync_with_stdio(false);
using namespace std;
#define lli long long int
#define endl '\n'
#define deb cout<<"sab_badhiya"<<endl;
// const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
const long INF = 1000 * 1000 * 1000;
const long long int mod = 1000000007;
int dp[100050];
int main(){
  FASTIO
  int n;
  cin>>n;
  int a[n+2];
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = abs(a[2]-a[1]);
  for(int i = 3; i <= n; i++) {
    dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n]<<endl;
}


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

using namespace std;

const int N = 100010;

int n;
int h[N];
int f[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i];
    memset(f, 0x3f, sizeof f);
    f[1] = 0;
    for (int i = 2; i <= n; i++) {
        f[i] = min(f[i - 1] + abs(h[i] - h[i - 1]), f[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << f[n] << endl;
    return 0;
}

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

int main() {
  set<ll> v;
  for (int i = 0; i < 100000; i++) {
    int s = 0;
    for (int j = 1; j <= i; j *= 10) {
      s += i % (10 * j) / j;
    }

    for (int j = 0; j <= 13; j++) {
      ll d = 1;
      for (int k = 0; k < j; k++) {
        d *= 10;
      }
      // ((i + 1) * d - 1) / (s + 9 * j) <= ((i + 2) * d - 1) / (s + 9 * j + 1)
      if (((i + 1) * d - 1) * (s + 9 * j + 1) <= ((i + 2) * d - 1) * (s + 9 * j)) {
        v.insert((i + 1) * d - 1);
      }
    }
  }
  v.erase(0);

  int k;
  cin >> k;
  auto it = begin(v);
  for (int i = 0; i < k; i++, it++) {
    cout << *it << endl;
  }
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

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

		while(sc.hasNext())
		{
			int n = sc.nextInt();
			int ans =0;
			boolean a[] = new boolean [n+1];
			Arrays.fill(a, true);
			a[0]=a[1]=false;

			for (int p=2; p*p<=n; p++) 
			{
				if (!a[p]) 
					continue;
				for (int j = p+p; j<= n; j += p)   //合成数jを消す
				{ 
					a[j] = false;
				}
			}
			for(int i =0; i<=n; i++)
			{
				if(a[i])
					ans++;
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,q;
    cin >> n >> q;
    int A[n];
    REP(i,n) cin >> A[i];
    int ruiseki[n + 1],gu[n+1],ki[n + 1];
    ruiseki[0] = 0;
    REP(i,n) ruiseki[i+1] = ruiseki[i] + A[i];
    gu[0] = 0;
    ki[0] = 0;
    REP(i,n){
        gu[i + 1] = gu[i];
        ki[i + 1] = ki[i];
        if(i %2 == 0) gu[i + 1] += A[i];
        else ki[i + 1] += A[i];
    }

    REP(i,q){
        int x;
        cin >> x;

        int l = 0;
        int r = n / 2 ;
        if(n %2 == 1) r ++;
        while(l + 1 < r){
            int mid = ( l + r) / 2;
            if(  A[n - 1 -mid] - x >=  x - A[n-1 - mid * 2 ]  ) l = mid;
            else r = mid;
        }
        int res = 0;
        res = ruiseki[n] - ruiseki[n - r];
        if(n %2 == 1){
            res += gu[ max(llong(0),n - 2 * r)];
        }
        else{
            res += ki[n - 2 * r];
        }
        cout << res << endl;

    }



}

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

int main(int argc, const char * argv[]) {
    int a,b,c;
    cin >> a >> b >> c;
    if (max(a,max(b,c)) == 7 && min(a,b) == 5 && min(b,c) == 5){
      cout << "YES";
    } else {
      cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p1, p2 = (0, 0), (100, 0)
ans_ls = [p1, p2]

def koch(d, p1, p2):
	if d == n:
		return
	s = (2/3*p1[0] + 1/3*p2[0], 2/3*p1[1] + 1/3*p2[1])
	t = (1/3*p1[0] + 2/3*p2[0], 1/3*p1[1] + 2/3*p2[1])

	R = [[1/2, -(3**(1/2))/2], [(3**(1/2))/2, 1/2]]
	u = (R[0][0]*(t[0] - s[0]) + R[0][1]*(t[1] - s[1]) + s[0],
		R[1][0]*(t[0] - s[0]) + R[1][1]*(t[1] - s[1]) + s[1])
	ans_ls.extend([s, u, t])

	koch(d + 1, p1, s)
	print(*s)
	koch(d + 1, s, u)
	print(*u)
	koch(d + 1, u, t)
	print(*t)
	koch(d+1, t, p2)

print(*p1)
koch(0, p1, p2)
print(*p2)


Measured memory_bytes: 6216
#include<bits/stdc++.h> 
using namespace std; 
#define M 1e9+7
#define int long long
#define lli long long int
#define I 10e5

int32_t main() 
{ 
   ios_base::sync_with_stdio(false);cin.tie(NULL); 
   
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout); 
   #endif
   int n;
   cin>>n;
   int sum = 0;
   int prev, curr;
   vector<int> a(n), b(n), c(n);
   for(int i=0;i<n;i++)
   {
      cin>>a[i]>>b[i]>>c[i];
   }
   int dp[n][3];
   dp[0][0] = a[0];
   dp[0][1] = b[0];
   dp[0][2] = c[0];
   for(int i=1;i<n;i++)
   {
      dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i];

      dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b[i];

      dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c[i];
   }
   cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
}

Measured memory_bytes: 7796
import java.util.*;
 class Main{

     public static void main(String []args){
        Scanner scan = new Scanner(System.in);
        int d = scan.nextInt();
        int n =scan.nextInt();
        
        
      	if(n==100){
          System.out.println((int)Math.pow(100,d)*(n+1));
        }
       else{
         System.out.println((int)Math.pow(100,d)*n);
       }
     }
}

Measured memory_bytes: 22740
#include <stdio.h>

int main(void)
{
	int Wa, Ha, xa, ya, ra, ka, ki, ku, ke;
	scanf("%d %d %d %d %d", &Wa, &Ha, &xa, &ya, &ra);
	ka = xa - ra;
	ki = xa + ra;
	ku = ya - ra;
	ke = ya + ra;

	if (ka >= 0 && ki <= Wa && ku >= 0 && ke <= Ha)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 584
import math
import sys
from collections import defaultdict
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
n, k = invr()
#A = invr()

A = [i for i in range(n + 1)]

res = 0
small = sum(A[:k])
large = sum(A[-k:])
for cLen in range(k, n + 2):
	# print small, large
	res = (res +  large - small + 1 ) % (10 ** 9 + 7)
	if cLen != n + 1:
		small += A[cLen]
		large += A[-cLen - 1]

print res


Measured memory_bytes: 85180
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,M; cin>>N>>M;
    vec A(M),B(M);
    vec C;
    set<int> D;
    REP(i,M){
        cin>>A[i]>>B[i];
        if(A[i]==1) C.push_back(B[i]);
        if(B[i]==N) D.insert(A[i]);
    }
    bool ans = false;
    REP(i,C.size()){
      if(D.find(C[i])!=D.end()) ans = true;
    }
    if(ans) Out("POSSIBLE");
    else Out("IMPOSSIBLE");
}


Measured memory_bytes: 8820
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
   // FI(); /// skip this line for compile
    int k,cnt=1;
    cin >> k;
    if(k%2==0 || k%5==0) cout << -1 << endl;
    else{
        int n = 0;
        while(true){
            n=(n*10+7)%k;
            if(n==0) break;
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}



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

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


def solve(a, b):
    n = int(input())
    impassables = [tuple(map(int, input().split())) for _ in range(n)]
    dp = [[0] * (a+1) for _ in range(b+1)]
    dp[0][1] = 1

    for y in range(1, b+1):
        for x in range(1, a+1):
            if (x, y) not in impassables:
                dp[y][x] = dp[y-1][x] + dp[y][x-1]
    return dp[-1][-1]


def main(args):
    while True:
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            break
        result = solve(a, b)
        print(result)


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

Measured memory_bytes: 7720
n1 = int(input())
d1 = [int(i) for i in input().split()]

r1 = 0

for i1 in range(n1 - 1):
    for i2 in range(n1 - i1 - 1):
        r1 += d1[i1] * d1[i2 + i1 + 1]

print(r1)

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int min(int a,int b)
{
	return a<b?a:b;
}
int max(int a,int b)
{
	return a<b?b:a;
}
int dp[1000090],a[10000],b[10000];
int main()
{
	memset(dp,0x7f,sizeof(dp));
	int n,now = 1,i = 0;scanf("%d",&n);
	while(now<=100000)
	{
		now*=6;
		a[++i]=now;
	}
	i=1;now=1;
	while(now<=100000)
	{
		now*=9;
		b[++i]=now;
	}
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		dp[i]=min(dp[i],i);
		for(int k=1;k<=10;k++)
		{
			if((i-a[k])>=0)
			{
				dp[i]=min(dp[i],dp[i-a[k]]+1);	
			}
			if((i-b[k])>=0)
			{
				dp[i]=min(dp[i],dp[i-b[k]]+1);
			}
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}

void yes() {
	cout << "Yes" << endl;
}

void no() {
	cout << "No" << endl;
}

int main() {
	int n;
	cin >> n;
	int temp;
	rept(i, n) {
		cin >> temp;
		if (temp % 2 == 0) {
			if (temp % 5 != 0 && temp % 3 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	
	
	cout << "APPROVED" << endl;

	

	system("pause");
	return 0;
}


Measured memory_bytes: 504
from scipy.sparse.csgraph import dijkstra
N,M = map(int,input().split())
edge = [[int(x) for x in input().split()] for _ in range(M)]

graph = [[0]*(N+1) for _ in range(N+1)]
# 連結している部分は1
for a,b in edge:
    graph[a][b] = 1
    
answer = 0
INF = 10 ** 9
for a,b in edge:
    graph[a][b] = INF
    # directed = False : 無向グラフ
    # indices = a : 始点
    # distはaからスタートしてそれぞれの点にたどり着くまでの最短距離
    dist = dijkstra(graph, indices = a, directed = False)
    if dist[b] >= INF:
        answer += 1
    graph[a][b] = 1
 
print(answer)

Measured memory_bytes: 17476
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll H, W;
string S[30];

ll ans;

ll gcd(ll x, ll y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

void init()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		cin >> S[i];
	}
}

void output()
{
	cout << ans << endl;
}



void solve()
{
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (S[i][j] == '#') continue;
			ll cs[30][30];
			for (int k = 0; k < H; k++)
			{
				for (int l = 0; l < W; l++)
				{
					cs[k][l] = INF;
				}
			}
			

			priority_queue<T, vector<T>, greater<T>> que;
			que.push(T(0, P(i, j)));
			while (que.size())
			{
				T t = que.top(); que.pop();

				if (cs[t.second.first][t.second.second] != INF) continue;

				cs[t.second.first][t.second.second] = t.first;

				if (t.second.first > 0)
				{
					if (cs[t.second.first - 1][t.second.second] == INF && S[t.second.first - 1][t.second.second] != '#') {
						que.push(T(t.first + 1, P(t.second.first - 1, t.second.second)));
					}
				}
				if (t.second.second > 0)
				{
					if (cs[t.second.first][t.second.second - 1] == INF && S[t.second.first][t.second.second - 1] != '#') {
						que.push(T(t.first + 1, P(t.second.first, t.second.second - 1)));
					}
				}
				if (t.second.first < H - 1)
				{
					if (cs[t.second.first + 1][t.second.second] == INF && S[t.second.first + 1][t.second.second] != '#') {
						que.push(T(t.first + 1, P(t.second.first + 1, t.second.second)));
					}
				}
				if (t.second.second < W - 1)
				{
					if (cs[t.second.first][t.second.second + 1] == INF && S[t.second.first][t.second.second + 1] != '#') {
						que.push(T(t.first + 1, P(t.second.first, t.second.second + 1)));
					}
				}
			}
			for (int k = 0; k < H; k++)
			{
				for (int l = 0; l < W; l++)
				{
					if (S[k][l] == '#') continue;
					ans = max(cs[k][l], ans);
				}
			}
		}
	}
}

int main()
{
	init();

	solve();



	output();
	ll N;
	cin >> N;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?a:-(a))
int N,A,B,C;
int l[8];
int dfs(int cur,int a,int b,int c) {
   if (cur == N) {
      if (MIN(MIN(a, b), c) > 0) {
         return ABS(a - A) + ABS(b - B) + ABS (C - c) - 30;
      } else {
         return 1000000;
      }
   }
   int ret0 = dfs(cur + 1, a, b, c);
   int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
   int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
   int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
   return MIN(MIN(MIN(ret2,ret3),ret1),ret0);
}

int main(void) {
   cin >> N >> A >> B >> C;
   for (int i = 0; i < N; i++) {
      cin >> l[i];
   }
   cout << dfs(0,0,0,0) << endl; 
}


Measured memory_bytes: 256
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

ans = 0

for i in 0..a 
 for j in 0 .. b
#  500*i + 100*j + 50*k = x
 k = x/50 - 10*i - 2*j 
 if k >= 0 && k <= c
     ans += 1 
 end
 end
 
end

puts ans


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

long long int ans=0,t;

void f(long long int k,bool r3,bool r5,bool r7){
    if(t<k)
        return ;
    else if(r3&&r5&&r7)
        ans++;
    f(10*k+3,true,r5,r7);
    f(10*k+5,r3,true,r7);
    f(10*k+7,r3,r5,true);
}

int main()
{
    scanf("%lld",&t);
    f(3,true,false,false);
    f(5,false,true,false);
    f(7,false,false,true);
    printf("%lld",ans);
}


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

int main()
{
    string input = "";

    cin >> input;

    char tmp0 = input[0];
    char tmp1 = input[1];
    char tmp2 = input[2];
    char tmp3 = input[3];
    
    if(tmp0 == tmp1 && tmp0 != tmp2){

        if(tmp2 == tmp3){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    }else if(tmp0 == tmp2 && tmp0 != tmp1){

        if(tmp1 == tmp3){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    }else if(tmp0 == tmp3 && tmp0 != tmp1){

        if(tmp1 == tmp2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=1,aa[220000],ans=0;
pair<int,int> pp[220000];
string s,sa[220000],sb[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cnt*=i+1;
        cnt%=INF;
    }
    cout<<cnt;
}

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

int dp[3030][3030];
pair<int, int> prv[3030][3030];

int main() {
	string s;
	string t;
	cin >> s >> t;

	prv[0][0] = { 0, 0 };
	for (int i = 1; i <= s.size(); i++)
		for (int j = 1; j <= t.size(); j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				prv[i][j] = { i - 1, j - 1 };
			}

			if (dp[i - 1][j] > dp[i][j]) {
				dp[i][j] = dp[i - 1][j];
				prv[i][j] = { i - 1, j };
			}

			if (dp[i][j - 1] > dp[i][j]) {
				dp[i][j] = dp[i][j - 1];
				prv[i][j] = { i, j - 1 };
			}
		}

	if (dp[s.size()][t.size()] == 0) {
		cout << "";
		return 0;
	}

	string sol = "";
	pair<int, int> tmp = { s.size(), t.size() };
	while (tmp != make_pair(0, 0)) {
		//cout << tmp.first << " " << tmp.second << endl;
		auto last = prv[tmp.first][tmp.second];
		//cout << "last " << last.first << " " << last.second << endl;
	//if (last.first == -1) break;
		if (tmp.first - last.first == 1 && tmp.second - last.second == 1) {
			//cout << "opk" << endl;
			//cout << s[tmp.first - 1] << endl;
			sol += s[tmp.first - 1];
		}
		tmp = last;
	}

	reverse(sol.begin(), sol.end());

	//cout << dp[s.size()][t.size()] << endl;
	cout << sol;


	return 0;
}

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

int main(void)
{
  char str[21];
  int i;

  while(cin >> str)
  {
    for(i = 0;str[i+1] != '\0';i++);
    for(;i != EOF;i--){
      cout << str[i];
    }
    puts("");
  }
}

Measured memory_bytes: 1100
n = int(input())
stair = input().split(' ')

stair[0] = int(stair[0]) - 1
for i in range(0, n - 1):
  if (int(stair[i]) < int(stair[i+1])):
    stair[i+1] = int(stair[i+1]) - 1

  if (int(stair[i]) > int(stair[i+1])):
    print("No")
    exit()
print("Yes")



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

int count(int a, int b, int c){
	int ans=0;
	int day=0;
	while(ans<c){
		ans+=a;
		day++;
		if(day%7==0){
			ans+=b;
		}
	}
	return day;
}

int main(int argc, char *argv[]){
	int a,b,c;
	int ans;
	scanf("%d%d%d",&a,&b,&c);

	ans = count(a,b,c);

	printf("%d\n",ans);
	exit(0);
}


Measured memory_bytes: 2148
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  
  vector<ll> A;
  REP(i,3*N){
    ll a;
    cin>>a;
    A.PB(a);
  }
  SORT(A);
  REVERSE(A);
  REP(i,N) ans+=A.at(2*i+1);
  
  co(ans);
  return 0;
}

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

int main(){
  char str[1200];
  int r[26];
  unsigned int i;
  int j;

  for(i=0; i<26; ++i){
    r[i]=0;
  }
  
  while(fgets(str,sizeof str,stdin) != NULL){
  
    for(i=0; i<strlen(str); ++i){
      if('A'<=str[i] && str[i]<='Z'){
	str[i]+=32;
	for(j=0; j<26; ++j){
	  if(str[i]=='a'+j){
	    ++r[j];
	    break;
	  }
	}
      }
      else if('a'<=str[i] && str[i]<='z'){
	for(j=0; j<26; ++j){
	  if(str[i]=='a'+j){
	    ++r[j];
	    break;
	  }
	}
      }
    }
  }
    
  for(i=0; i<26; ++i){
    printf("%c : %d\n",'a'+i,r[i]);
  }
  

  return 0;
}



Measured memory_bytes: 2584
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int mod=998244353;
struct edge
{
	int v,nxt;
}e[3][500005];
int n,m[3],h[3][100005],t[3],a[3][1000005],vis[100005],bs,inv2,lim,f[1000005];
vector<int> b[100005];
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int fpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return ans;
}
void add(int u,int v,int fl)
{
	e[fl][++t[fl]].v=v;
	e[fl][t[fl]].nxt=h[fl][u];
	h[fl][u]=t[fl];
}
void fwt(int *a)
{
	for(int k=1;k<lim;k<<=1)
		for(int i=0,r=k*2;i<lim;i+=r)
			for(int j=0;j<k;j++)
			{
				int x=a[i+j],y=a[i+j+k];
				a[i+j]=addmod(x+y);
				a[i+j+k]=submod(x-y);
			}
}
void ifwt(int *a)
{
	for(int k=1;k<lim;k<<=1)
		for(int i=0,r=k*2;i<lim;i+=r)
			for(int j=0;j<k;j++)
			{
				int x=a[i+j],y=a[i+j+k];
				a[i+j]=1ll*addmod(x+y)*inv2%mod;
				a[i+j+k]=1ll*submod(x-y)*inv2%mod;
			}
}
void solve(int fl)
{
	for(int i=1;i<=n;i++)
		b[i].clear();
	for(int i=n;i>0;i--)
	{
		int nw=0;
	//	printf("fl=%d,nw=%d,i=%d\n",fl,nw,i);
		for(int j=0;j<(int)b[i].size();j++)
			vis[b[i][j]]=1;
		while(vis[nw]) nw++;
		a[fl][nw]=addmod(a[fl][nw]+fpow(bs,i));
		for(int j=h[fl][i];j;j=e[fl][j].nxt)
		{
			int v=e[fl][j].v;
			b[v].push_back(nw);
		}
		for(int j=0;j<(int)b[i].size();j++)
			vis[b[i][j]]=0;
	}
}
int main()
{
	bs=fpow(10,18);
	inv2=fpow(2,mod-2);
	scanf("%d",&n);
	lim=1;
	while(lim<=n) lim<<=1;
	for(int fl=0;fl<3;fl++)
	{
		scanf("%d",&m[fl]);
		for(int i=1;i<=m[fl];i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v,fl);
			add(v,u,fl);
		}  
		solve(fl);
		fwt(a[fl]);
	}
	for(int i=0;i<lim;i++)
		f[i]=1ll*a[0][i]*a[1][i]%mod*a[2][i]%mod;
	ifwt(f);
	printf("%d",f[0]);
	return 0;
}

Measured memory_bytes: 28288
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int func(int num){
    int cnt = 0;
    int table[] = {500,100,50,10};
    rep(i,0,4){
        cnt += num / table[i];
        num %= table[i];
    }
    return cnt;
}
main(){
    int N;
    cin >> N;
    while(N){
        int coin[4];
        rep(i,0,4)cin >> coin[i];
        int table[4] = {10,50,100,500};
        int mini = INF, sum = coin[0] + coin[1] + coin[2] + coin[3];
        int mi[4];
        rep(i,0,21)if(coin[0] >= i)rep(j,0,21)if(coin[1] >= j)rep(k,0,21)if(coin[2] >= k)rep(l,0,21)if(coin[3] >= l){
            int pay = i * 10 + j * 50 + k * 100 + l * 500;
            if (pay >= N){
                int tmp = sum - (i + j + k + l) + func(pay - N);
                if(mini > tmp){
                    mini = tmp;
                    mi[0] = i,mi[1] = j,mi[2] = k,mi[3] = l;
                }
            }
        }
        //cout << mini << endl;
        rep(i,0,4){
            if(mi[i])cout << table[i] << " " << mi[i] << endl;
        }
        cin >> N;        
        if(N)cout << endl;
    }
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

class UnionFind{
    public:
        ll size;
        vll v;

        UnionFind(ll n){
            this->v = vll(n);
            rep(i, n) this->v[i] = i;
        }

        ll root(ll n){
            if(n!=v[n]) return v[n] = root(v[n]);
            return n;
        }

        void unite(ll l, ll r){
            ll lroot = root(l);
            ll rroot = root(r);
            if(lroot!=rroot) this->v[rroot] = lroot;
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, M;
    cin >> N >> M;
    vll A(M), B(M);
    rep(i, M) cin >> A[i] >> B[i];

    UnionFind uf(N);
    rep(i, M) uf.unite(A[i]-1, B[i]-1);
    unordered_set<ll> s;
    rep(i, N) s.insert(uf.root(i));
    cout << s.size()-1 << endl;
}


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

int main(){
	int N;
	cin>>N;
	int goods[N];
	int max_price;
	int sum=0;
	for(int i=0;i<N;i++){
		cin>>goods[i];
		if(i==0){
			max_price=goods[i];
		}
		if(i != 0 && max_price < goods[i]){
			max_price=goods[i];
		}
		sum += goods[i];
	}
	cout << sum - max_price/2;
	return 0;
}	


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

const int MAX = 8000;
int main() {
	string s;
	int x, y;
	int ax[MAX], ay[MAX], bx = 0, by = 0, xsum = 0, ysum = 0;
	bool p[MAX], q[MAX];
	for (int i = 0;i < MAX;i ++) {
		ax[i] = 0;
		ay[i] = 0;
		p[i] = false;
		q[i] = false;
	}
	cin >> s >> x >> y;
	for (int i = 0;i < s.length();i ++) {
		if (s[i] == 'F') x --;
		else {
			bool directX = false;
			for (int j = i + 1;j < s.length();j ++) {
				if (s[j] == 'T') {
					if (ax[bx])bx ++;
					if (ay[by])by ++;
					directX = !directX;
				}
				else if (directX) ax[bx] ++;
				else ay[by] ++;
			}
			break;
		}
	}
	for (int i = 0;ax[i] != 0;i ++) xsum += ax[i];
	for (int i = 0;ay[i] != 0;i ++) ysum += ay[i];
	/*
	for (int i = 0;ax[i] != 0;i ++) cout << ax[i] << " ";
	cout << endl;
	for (int i = 0;ay[i] != 0;i ++) cout << ay[i] << " ";
	cout << endl;
	*/
	p[0] = true;
	for (int i = 0;ax[i] != 0;i ++) {
		for (int j = xsum;j >= 0;j --) {
			if (p[j]) p[j + ax[i]] = true;
		}
	}
	
	q[0] = true;
	for (int i = 0;ay[i] != 0;i ++) {
		for (int j = ysum;j >= 0;j --) {
			if (q[j]) q[j + ay[i]] = true;
		}
	}
	/*
	for (int i = 0;i <= xsum;i ++) cout << p[i];
	cout << endl;
	for (int i = 0;i <= ysum;i ++) cout << q[i];
	cout << endl;
	*/
	if ((xsum + x) < 0 || (xsum + x) % 2 == 1 || (ysum + y) < 0 || (ysum + y) % 2 == 1) cout << "No";
	else if (p[(xsum + x) / 2] && q[(ysum + y) / 2]) cout << "Yes";
	else cout << "No";
	return 0;
}
// 部分和問題

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>

using namespace std;

int main(void) {

	bool firstlet = true;

	long long n, num = 1, i, j, tmp, first;
	string s;

	cin >> n >> s;

	long long d[n];

	for (int i = 0; i < n; i++)
	{
		d[i] = 1;
	}

	//num = n;
	//tmp = n;

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

	for (int i = 0; i < n; i++)
	{
		if (firstlet == true) {
			d[i] = 1;
			first = i;
		}
		else {
			d[i] = 0;

			d[first]++;
		}

		if (i != n - 1) {
			if (s[i] != s[i + 1]) {
				firstlet = true;
			}
			else {
				firstlet = false;
			}
		}

		//cout << i << " " << d[i] << " " << "\n";
	}



	/*	for (j = i + 1; j < n; j++)
		{
			if (i != n - 1) {
				if (s[i] == s[j]) {

					d[i]++;
					d[j] = 0;
					//printf("i=%d,j=%d\n", i, j);

				}
			}
		}
	}*/


	for (int i = 0; i < n; i++)
	{
		if (d[i] != 0) {
			num = num *(d[i]+1);

			num = num % ((long long)(pow(10, 9)) + 7);
		}

		//printf("d[%d]=%d,num=%d\n",i,d[i], num);
		
	}

	num--;

	//num = int(pow(2, tmp));

	cout << num << "\n";

	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
   	int n, k;
   	cin >> n >> k;
   	int r, s, p;
   	cin >> r >> s >> p;
   	str t;
   	cin >> t;
   	int sum = 0;
   	fi(0, k) {
   		vi pdp = {0, 0, 0};
   		for (int j = i; j < n; j += k) {
   			vi dp(3, 0);
   			dp[0] = max(pdp[1], pdp[2]) + r * (t[j] == 's');
   			dp[1] = max(pdp[0], pdp[2]) + s * (t[j] == 'p');
   			dp[2] = max(pdp[0], pdp[1]) + p * (t[j] == 'r');
   			pdp = dp;
   		}
   		sum += max(max(pdp[0], pdp[1]), pdp[2]);
   	}
   	cout << sum << '\n';
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
struct edge { int v, w; };

int main() {
	int x, y; cin >> x >> y;
	cout << y * 2 - x << endl;
}


Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
//		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(br.readLine());
//		int b = Integer.parseInt(tmpArray[1]);
//		int c = Integer.parseInt(tmpArray[2]);
//		int y = Integer.parseInt(tmpArray[3]);
//		int r = Integer.parseInt(tmpArray[4]);
		String[] tmpArray = br.readLine().split(" ");
		int[] input = new int[n];
		long sum = 0;
		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
			sum += input[i];
		}
		
		Arrays.sort(input);
		System.out.printf("%d %d %d\n", input[0], input[input.length - 1], sum);
		
//		while(true){
//			String[] tmpArray = br.readLine().split(" ");
//			int a = Integer.parseInt(tmpArray[0]);
//			int b = Integer.parseInt(tmpArray[2]);
//			if(tmpArray[1].equals("?")){
//				break;
//			}
//			String op = tmpArray[1];
//			if(op.equals("+")){
//				System.out.println(a+b);
//			}
//			if(op.equals("-")){
//				System.out.println(a-b);
//			}
//			if(op.equals("*")){
//				System.out.println(a*b);
//			}
//			if(op.equals("/")){
//				System.out.println(a/b);
//			}
//			
//		}

		//		int[] array = new int[3];
//		array[0] = a; array[1] = b; array[2] = c;
//
//		Arrays.sort(array);
//		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

Measured memory_bytes: 29548
// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    ll ans=0,bf=0;
    for(int i=0;i<sz(s);i++){
	if(s[i]=='B') bf++;
	else ans+=bf;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1356
#include <cstdio>
int a[16][16];
long long dp[18][16];
int main()
{
    while (true) {
        int h, w;
        scanf("%d%d", &w, &h);
        if (!(w | h)) break;
        for (int i = 0; i < 16; ++i) for (int j = 0; j < 16; ++j)
            dp[i][j] = 0;
        for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j)
            scanf("%d", &a[i][j]);

        for (int j = 0; j < w; ++j)
            if (a[0][j] == 0) dp[0][j] = 1;
        for (int i = 1; i < h; ++i) for (int j = 0; j < w; ++j) {
            if (a[i][j] == 1) continue;
            if (a[i-1][j] != 2) dp[i][j] = dp[i-1][j];
            if (a[i][j] == 0) {
                if (j > 0 && a[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
                if (j < w-1 && a[i-1][j+1] == 0) dp [i][j] += dp[i-1][j+1];
            }
            if (i > 1 && a[i-2][j] == 2) dp[i][j] += dp[i-2][j];
        }
        for (int j = 0; j < w; ++j) {
            dp[h][j] = dp[h-1][j];
            if (h > 1 && a[h-2][j] == 2) dp[h][j] += dp[h-2][j];
        }
        int res = 0;
        for (int j = 0; j < w; ++j) res += dp[h][j];
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 0