akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

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

	cout<<(char)('A'+a[0]-'a')<<(char)('A'+b[0]-'a')<<(char)('A'+c[0]-'a')<<endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [input().split() for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(s[int(input())-1])

if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  int* x = new int[100];
  int* y = new int[100];
  int* h = new int[100];
  int minH;
  for(int i=0;i<n;i++){
    cin >> x[i];
    cin >> y[i];
    cin >> h[i];
    if(i==0) minH = h[i];
    else minH = min(minH,h[i]);
    //cout << x[i] << " " << y[i] << " " << h[i] << endl;
  }
  for(int candH=minH; candH<(minH+205); candH++){
    for(int xi = 0;xi<101;xi++){
      for(int yi = 0;yi<101;yi++){
        bool allpassed = true;
        for(int i=0;i<n;i++){
          int predH = max(0,h[i]-abs(x[i]-xi)-abs(y[i]-yi));
          //if(predH != 0 && candH == 6)cout << candH << " " << xi << " " << yi << " " << predH << endl;
          if(h[i] != max(0,candH-abs(x[i]-xi)-abs(y[i]-yi))){
            allpassed = false;
            break;
          }
        }
        if(allpassed){
          cout << xi << " " << yi << " " << candH << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


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

int main() {
    long w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << (double) w * h / 2.0 << ' ';
    if (x * 2 == w && y * 2 == h)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        ll a,b,m;
        cin >> a >> b >> m;
        vll x(a + 1), y(b + 1);
        ll minx = 1e9, miny = 1e9;
        REP(i,1,a){
                cin >> x[i];
                minx = min(minx, x[i]);
        }
        REP(i,1,b){
                cin >> y[i];
                miny = min(miny, y[i]);
        }
        ll ans = minx + miny;
        REP(i,1,m){
                ll p,q,r;
                cin >> p >> q >> r;
                ans = min(ans, x[p] + y[q] - r);
        }
        cout << ans << endl;
}

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

int arr[4];

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i != n; ++i)
    {
        string s;
        cin >> s;
        for (int j = 1; j != s.size(); ++j)
            if (s[j - 1] == 'A' && s[j] == 'B') ++ans;
        int tmp = 0;
        if (s[0] == 'B') tmp |= 1;
        if (s[s.size() - 1] == 'A') tmp |= 2;
        ++arr[tmp];
    }
    
    if (arr[3])
    {
        if (!arr[1] && !arr[2])
            ans += arr[3] - 1;
        else
            ans += arr[3] + min(arr[1], arr[2]);
    }
    else
        ans += min(arr[1], arr[2]);
    
    cout << ans;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import zip_longest

    o = input()
    e = input()

    res = ""
    for a, b in zip_longest(o, e, fillvalue=""):
        res += a
        res += b

    print(res)


if __name__ == '__main__':
    main()


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

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

int N,M;
bool G[50][50] = {};
bool V[50] = {};

void f(int u){
    V[u] = true;
    rep(v,N){
        if(!G[u][v]) continue;
        if(V[v]) continue;
        f(v);
    }
}
 
int main() {
    cin >> N >> M;
    pair<int,int> E[M];
    rep(m,M){
        int i,j;
        cin >> i >> j;
        G[i-1][j-1] = true;
        G[j-1][i-1] = true;
        E[m] = make_pair(i-1,j-1);
    }
    //
    int count = 0;
    rep(i,M){
        rep(j,N){
            V[j] = false;
        }
        G[E[i].first][E[i].second] = false;
        G[E[i].second][E[i].first] = false;

        f(0);

        rep(j,N){
            if(!V[j]){
                count++;
                break;
            }
        }

        G[E[i].first][E[i].second] = true;
        G[E[i].second][E[i].first] = true;
    }

    cout << count << endl;

    return 0;
} 

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

typedef long long ll;

ll mod=1000000007;

ll power(ll b,ll n)
{
    if(n==0)
        return 1LL;
    ll p=power(b,n/2);
    if(n&1)
        return (b*((p*p)%mod))%mod;
    return (p*p)%mod;
}

ll fact(ll n)
{
    ll ans=1;
    for(int i=1;i<=n;i++)
        ans=(ans*i)%mod;
    return ans;
}

int main()
{
    ll n;
    cin>>n;
    if(n==1)
        cout<<0;
    else if(n==2)
        cout<<2;
    else
        // cout<<(((n*(n-1))%mod)*power(8,n-2))%mod;
        cout<<((((power(10,n)-power(9,n)+mod)%mod)-power(9,n)+mod)%mod+power(8,n)+mod)%mod;
    return 0;
}

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

int main(){
    int R, G, B, N;
    cin >> R >> G >>B >>N;
    int count=0;
    int tempN,temptempN;
    for(int r=0; r<=N/R; r++){
        tempN =N;
        tempN -= R*r;
        if(tempN == 0){
            count++;
        }else{
            for(int g=0; g<=tempN/G; g++){
                temptempN = tempN;
                temptempN -= G*g;
                if(temptempN%B == 0){
                    count++;
                }
            }
        }
    }
    cout << count<< endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define ci(n) cin >> n
#define co(n) cout << n << endl
using namespace std;

int main(){
  string s;
  cin >> s;
  int a;
  a=s.size()-2;
  cout << s[0] << a << s[a+1] << endl;
  
  return 0;
}


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

using namespace std;
typedef long long ll;
const double PI = 3.14159265;

void fastInOut();

const int N = 100005;
int cnt[N];
bool flag[N];

int main() {

    fastInOut();
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cnt[i] = 1;
    flag[1] = 1;
    int x, y;
    while (m--) {
        cin >> x >> y;
        cnt[x]--;
        cnt[y]++;
        if (flag[x]) {
            flag[y] = 1;
            if (cnt[x] == 0)
                flag[x] = 0;
        }
    }
    int res = 0;
    for (int i = 1; i <= n; i++)
        res += flag[i];
    cout << res;
    return 0;
}

void fastInOut() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
}

Measured memory_bytes: 768
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	x := getNextInt(scanner)
	t := getNextInt(scanner)
	fmt.Fprintln(writer, t*((n+x-1)/x))
}


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


int main()
{
    int n;
    cin>>n;
    if(n>0&&n<1000)
        cout<<"ABC"<<endl;
    else if(n>=1000&&n<1999)
        cout<<"ABD"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n;
	cin >> n;
	if (n<1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
}

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

using namespace std;

int gcd(ll a, ll b) {
    if(b == 0)return a;
    ll r = a % b;
    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    vector<ll> a,l,r,m;
    ll n;
    cin >> n;
    for(ll i=0;i<n;i++) {
        ll t;
        cin >> t;
        a.push_back(t);
    }
    sort(a.begin(),a.end());
    l.push_back(0);
    r.push_back(0);
    for(ll i=0;i<n;i++) {
        l.push_back(gcd(a[i],l[i]));
        r.push_back(gcd(a[n-1-i],r[i]));
    }
    for(ll i = 0;i < n;i++) {
        m.push_back(gcd(l[i],r[n-1-i]));
    }
    sort(m.begin(),m.end());
    cout << m[n-1] << endl;
}


Measured memory_bytes: 4124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
    string s;
    char ss[1000000];
    int q;
    cin >> s >> q;
    int l = 300000;
    int r = s.size() + l;
    for (int i = 0; i < s.size(); i++) {
        ss[l + i] = s[i];
    }
    l--;
    int cnt = 0;
    for (int _ = 0; _ < q; _++) {
        int t;
        cin >> t;
        if(t == 1) cnt++;
        else{
            int f;
            char c;
            cin >> f >> c;
            if(cnt % 2 == 0){
                if(f == 1) {
                    ss[l] = c;
                    l--;
                }
                else {
                    ss[r] = c;
                    r++;
                }
            }
            if(cnt % 2 == 1){
                if(f == 2) {
                    ss[l] = c;
                    l--;
                }
                else {
                    ss[r] = c;
                    r++;
                }
            }

        }
    }
    if(cnt % 2 == 0){
        for (int i = l + 1; i < r; i++) {
            cout << ss[i];
        }
    }
    else{
        for (int i = r - 1; i > l; i--) {
            cout << ss[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 1152
from itertools import groupby
s=input()
if s[0]=='>':
  s='<'+s
g=groupby(s)
a=[]
for i,j in g:
  a.append(len(list(j)))
def sum(n):
  return n*(n+1)//2
x=0
if len(a)%2==1:
  a+=[1]
for i in range(0,len(a),2):
  x+=sum(min(a[i],a[i+1])-1)
  x+=sum(max(a[i],a[i+1]))
print(x)

Measured memory_bytes: 8348
#include<bits/stdc++.h>
#define in inline
#define int long long
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
map<int,int>v;
int n,m,ans,a[200002];
signed main(){
	n=read();
	for(re int i=1;i<=n;++i){
		a[i]=read();
	}
	for(re int i=n;i;--i){
		ans+=v[-(i+a[i])];
		++v[a[i]-i];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 27948
#include <stdio.h>

int main(){
	int a, b;
	int G=0, H=0;
	int i=0;
	while(scanf("%d,%d", &a, &b)!=EOF)
	{
		G+=a*b;
		H+=b;
		i++;
	}
	H=H*10/i;
	if(H/i%10<=5)
	{
		H+=10;
		H/=10;
	}
	else
	{
		H/=10;
	}
	printf("%d\n%d\n", G, H);
	return 0;
}

Measured memory_bytes: 1020
a, b, c = map(int, input().split())

if a == b and b == c and a % 2 == 0:
    print(-1)
    exit()

OK = True
count = 0

while OK:
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        OK = False
        break
    diva = a//2
    divb = b//2
    divc = c//2
    a = divb + divc
    b = divc + diva
    c = diva + divb
    count += 1

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll N,M; cin>>N>>M;
  if(N==1&&M==1) cout<<"1"<<endl;
  else if(N==1){
    if(M>=2) cout<<M-2<<endl;
  }
  else if(M==1){
    if(N>=2) cout<<N-2<<endl;
  }
  else {
    ll ans=(N-2)*(M-2);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
  int l,r,d;
  cin>>l>>r>>d;
  int cou=0;
  for(int i=0;i<=r-l;i++){
    if((l+i)%d==0)
      cou++;
  }
  cout<<cou<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;


const double EPS = 1e-10;
const double PI = acos(-1.0);

struct PT {
  ll x, y;
  int id;
  PT() {}
  PT(ll x_, ll y_): x(x_), y(y_), id(-1) {}
  ll len2() const {
    return x * x + y * y;
  }
  double len() const {
    return sqrt(len2());
  }
  PT operator - (const PT &b) const {
    return PT(x - b.x, y - b.y);
  }
  ll operator * (const PT &b) const {
    return x * b.x + y * b.y;
  }
  ll operator % (const PT &b) const {
    return x * b.y - y * b.x;
  }
  bool operator < (const PT &b) const {
    return tie(x, y) < tie(b.x, b.y);
  }
};

const int MAXN = 123;
PT in[MAXN];
double ans[MAXN];

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    in[i].x = x;
    in[i].y = y;
    in[i].id = i;
  }
  sort(in, in + N);
  vector<PT> st;
  for (int i = 0; i < N; i++) {
    while (SZ(st) >= 2 && (st[SZ(st) - 1] - st[SZ(st) - 2]) % (in[i] - st[SZ(st) - 1]) < 0)
      st.pop_back();
    st.PB(in[i]);
  }
  for (int i = N - 2; i >= 0; i--) {
    while (SZ(st) >= 2 && (st[SZ(st) - 1] - st[SZ(st) - 2]) % (in[i] - st[SZ(st) - 1]) < 0)
      st.pop_back();
    st.PB(in[i]);
  }
  for (int i = 0; i < N; i++)
    ans[i] = 0;
  st.PB(st[1]);
  for (int i = 1; i < SZ(st) - 1; i++) {
    PT A = st[i - 1] - st[i];
    PT B = st[i + 1] - st[i];
    double tmp = A * B / (A.len() * B.len());
    //double ang = PI - acos(clamp(tmp, -1.0, 1.0)); // C++ 17 required
    double ang = PI - acos(min(max(tmp, -1.0), 1.0));
    ans[st[i].id] = ang / (2 * PI);
  }
  for (int i = 0; i < N; i++)
    printf("%.10f\n", ans[i]);
  double sum = 0;
  for (int i = 0; i < N; i++)
    sum += ans[i];
  //assert(fabs(sum - 1.0) < EPS);
  return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    i = 0
    while True:
        v = map( int, raw_input().split())
        if v[0] == 0:
            if v[1] == 0:
                break
        i += 1
        if v[0] > v[1]:
            print "{0} {1}".format(v[1],v[0])
        else:
            print "{0} {1}".format(v[0],v[1])

Measured memory_bytes: 4208
#include<iostream>
    using namespace std;
    int main()
    {
      int l,r,d,count=0;
      cin>>l>>r>>d;
      for(int i=l;i<=r;i++)
      {
        if(i%d==0)
          count++;
      }
      cout<<count<<endl;
      return 0;
    }

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

int main(){
    ll r, D;
    cin >> r >> D;
    ll x[11];
    cin >> x[0];
    for(int i=1; i<=10; i++){
        x[i] = r*x[i-1] - D;
        cout << x[i] << endl;
    }
}


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

public class Main {
	private static final long[] Ary = null;

	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{


			  String ab;
			  String ac;
			  String[] strAry;
			  int a=0;
			  int b=0;

              long d=0;
              int max=0;
              int min=0;


			      ab = input.readLine();
			   
		          a=Integer.parseInt(ab);
		          ac=input.readLine();
		          int Array[] =new int[a];

		         
		       
		          strAry = ac.split(" ");
		       
		          for(int i=0; i<a; i++){
	                 b=Integer.parseInt(strAry[i]);
	               
	                 Array[i]=b;
	               
	                 d+=Array[i];
	                 
		          }

		          max=Array[0];
		        
		          min=Array[0];

		          for(int j=0; j<a; j++){
		        	  if(max<Array[j]){
		        		
		        		  max=Array[j];
		        	  }
		        	  if(min>Array[j]){
		        		  min=Array[j];
		        	  }


		          }
		          System.out.println(min+" "+max+" "+d);






		    }catch(IOException e) {   System.out.println("Exception : " + e);

		    }
	}



}

Measured memory_bytes: 28688
def prime_factor(n):
    ass = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass


a, b = map(int, input().split())
a_prime = set(prime_factor(a))
b_prime = set(prime_factor(b))
ab_prime = list(a_prime & b_prime)
print(len(ab_prime)+1)



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

int main(){
    int n;
    cin >> n;
    deque<int> b;
    rep(i, n) {
        int a;
        cin >> a;
        if ((i+1)%2==n%2) b.push_front(a);
        else b.push_back(a);
    }
    rep(i, b.size()) {
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

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

struct edge { int to, cost; };
typedef pair<int, int> P; // firstは最短距離、secondは頂点の番号

const int VV = 222222;
const int INF = 1e8;
int V, M;
vector<edge> G[VV];
int d[VV];

void dijkstra(int s) {
   // 最短距離firstが小さい順に取り出せるようにする
   priority_queue<P, vector<P>, greater<P>> que;
   fill(d, d + V, INF); // 距離全てをINFで初期化
   d[s] = 0; // スタート地点を0で初期化
   que.push(P(0, s)); // キューに初期位置のコスト、初期位置をpush

   while (que.size()) {
      P p = que.top(); que.pop(); // p: 今の{最短距離、頂点番号}
      int v = p.second; // 今の頂点番号
      if (d[v] < p.first) continue; // 今見ている頂点の歴代最小距離 < 今見ている頂点の最短距離
      for (int i = 0; i < G[v].size(); i++) { // 今の頂点に隣接する頂点を調べる
         edge e = G[v][i];
         if (d[e.to] > d[v] + e.cost) { // 遷移先の頂点の歴代最小距離 > 今の距離 + 遷移コスト
            d[e.to] = d[v] + e.cost; // 歴代最小距離の更新
            que.push(P(d[e.to], e.to)); // 更新した遷移先の頂点をキューに突っ込む
         }
      }
   }
}

int main() {
   cin >> V >> M;
   for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      G[a].push_back({b, 1});
      G[b].push_back({a, 1});
   }

   dijkstra(0);

   if (d[V-1] == 2) {
      puts("POSSIBLE");
   } else {
      puts("IMPOSSIBLE");
   }

   return 0;
}

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

int main()
{
	char c[4];
	int cups[] = { 1, 0, 0 };
	while (cin >> c)
	{
		int tmp = cups[c[0] - 'A'];
		cups[c[0] - 'A'] = cups[c[2] - 'A'];
		cups[c[2] - 'A'] = tmp;
	}
	for (int i = 0; i < 3; i++)
	{
		if (cups[i] == 1)cout << (char)('A' + i) << endl;
	}
	return 0;
}

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

const int inf = pow(10,9);

int main(){
  int h, n;
  cin >> h >> n;
  map<int, int> magic;
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    if(magic.count(a)){
      if(magic.at(a) > b) magic.at(a) = b;
    }
    else magic[a] = b;
  }
  
  vector<int> dp(h+1, inf);
  dp.at(0) = 0;
  for(int i = 0; i < h; i++){
    for(auto now : magic){
      int dam = i + now.first, cost = dp.at(i) + now.second;
      if(dam > h ) dam = h;
      dp.at(dam) = min(dp.at(dam), cost);
    }
  }
  
  cout << dp.at(h) << endl;
}


Measured memory_bytes: 384
X,Y = map(int,input().split())
MOD = 10**9+7

if (X+Y)%3:
    print(0)
    exit()
n = (X+Y)//3
r = X-n
if not 0 <= r <= n:
    print(0)
    exit()

MAXN = r
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
def comb(n,r):
    ret = 1
    for i in range(r):
        ret *= n-i
        ret *= inv[i+1]
        ret %= MOD
    return ret

print(comb(n,r))

Measured memory_bytes: 16200
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<x<<endl;
#define Nmax 1000005
#define MOD 1000000007
using namespace std;

ll n,x,y,ans,lst,uz[Nmax],crt;

vector<pii> L,R;

bool comp(pii A, pii B){
    return A.first < B.first;
}

bool comp2(pii A, pii B){
    return A.first > B.first;
}

int main()
{
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> x >> y;
        L.push_back({y,i});
        R.push_back({x,i});
    }
    L.push_back({0,0});
    R.push_back({0,0});
    make_heap(L.begin(),L.end(), comp2);
    make_heap(R.begin(),R.end(), comp);


    for (int i=1;i<=n;i++){
        while(!R.empty() && uz[R[0].second] == 1){
            pop_heap(R.begin(),R.end(),comp);
            R.pop_back();
        }
        if (R.empty()) break;
        crt += R[0].first;
        uz[R[0].second] = 1;

        while(!L.empty() && uz[L[0].second] == 1){
            pop_heap(L.begin(),L.end(),comp2);
            L.pop_back();
        }
        if (L.empty()) break;
        crt -= L[0].first;
        uz[L[0].second] = 1;
        ans = max(ans, crt * 2);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4324
#include<stdio.h>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main ()
{
     int tmp[501][3];
     int n,ans[501];
     while (scanf ("%d",&n)!=EOF)
     {
         for (int i=0;i<n-1;i++)
            {scanf ("%d%d%d",&tmp[i][0],&tmp[i][1],&tmp[i][2]); ans[i]=0;}
          for (int i=0;i<n-1;i++)
          {


              for (int j=0;j<=i;j++)
              {
                 int mod=0;
                 ans[j]=max(ans[j],tmp[i][1]);
                mod = (ans[j]-tmp[i][1])%tmp[i][2];
                if (mod!=0) {ans[j]+=tmp[i][2] -mod; /*printf ("%d\n",mod);*/}
                  ans[j]+=tmp[i][0];
                 // printf ("a%d=%d\n",j,ans[j]);
              }
          }
          for (int i=0;i<n-1;i++)
            printf ("%d\n",ans[i]);
            printf ("0\n");
     }
    return 0;
}
/*
1 1 2
1 1 3
*/


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
using namespace std;
typedef unsigned long long ll;
#define rep(i, n) for ( int i = 0; i < n ; i ++)
int main()
{
	char s[20], t[20], u[20];
	int a, b;
	scanf("%s %s", s, t);
	scanf("%d %d", &a, &b);
	scanf("%s", u);
	if (memcmp(u, s, strlen(u)) == 0)a--;
	else b--;
	printf("%d %d", a, b);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby                                                                                                                               
# -*- coding: utf-8 -*-                                                                                                                       


ratch = false
pos = 0
(gets.to_i).times {
  par, n = gets.split

  if par == "("
    pos += n.to_i
  else
    pos -= n.to_i
  end
  if pos < 0
    ratch = true
  end
}

if ratch || pos != 0
  puts "NO"
else
  puts "YES"
end

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

int counter(int x){
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main(){
    int N;
    int A[20];
    int x[20][20];
    int y[20][20];

    cin >> N;
    for (int i = 1; i <= N; i++){
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++)
        {
            cin >> x[i][j] >> y[i][j];             
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++){
        bool ok = true;
        for(int i = 1; i <= N; i++){
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++){
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }   
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ long(x) for x in rd().split() ]

INF = 1000000000 * 2000 + 1

N, M = rdi()
a = []
b = []
c = []
for i in range(M):
        ai, bi, ci = rdi()
        a.append(ai)
        b.append(bi)
        c.append(ci)

t = {}
for i in range(N):
        t[i+1] = []
for i in range(M):
        ai = a[i]
        bi = b[i]
        ci = c[i]
        t[ai].append( (bi, ci) )


w = { 1: (0, []) }
q = [ 1 ]
while q:
        ai = q.pop()
        s = w[ai][0]
        p = w[ai][1]
        for bi, ci in t[ai]:
                if s == INF:
                        s2 = INF
                else:
                        s2 = s + ci
                if bi not in w:
                        w[bi] = (s2, p+[bi])
                        q.append(bi)
                else:
                        if s2 > w[bi][0]:
                                if bi in p:
                                        s2 = INF
                                w[bi] = (s2, p+[bi])
                                q.append(bi)

sn = w[N][0]
if sn == INF:
        print "inf"
else:
        print sn

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

int main()
{
    string S;
    cin >> S;
    int sum = 700;
    for(int i=0; i<3; i++)
    {
        if(S[i] == 'o')
        {
            sum += 100;
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
N, D = list(map(int, input().split()))
XS = [[0] * D for _ in range(N)]
for i in range(N):
	XS[i] = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		c1 = 0
		for k in range(D):
			c1 += (XS[i][k] - XS[j][k]) ** 2
		c2 = c1 ** 0.5
		if c2 == int(c2):
			ans += 1
print(ans)


Measured memory_bytes: 9360
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	m := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &m[i])
	}
	max := 0
	res := 0
	x := make([]int, n)
	x[n-1] = 0
	if n == 1 {
		fmt.Println(0)
	} else {
		for i := n - 2; i >= 0; i-- {
			if m[i] >= m[i+1] {
				res+=1
			} else {
				res = 0
			}
			if res > max {
				max = res
			}
		}
		fmt.Println(max)
	}

}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, p;
		int id, s;
		int k[];
		
		while (true) {
			n = sc.nextInt();
			p = sc.nextInt();
			if ((n | p) == 0) {
				break;
			}
			k = new int[n];
			id = 0;
			s = p;
			while (true) {
				if (s == 0) {
					s = k[id];
					k[id] = 0;
				} else {
					s--;
					k[id]++;
					if (k[id] == p) {
						break;
					}
				}
				id = (id + 1) % n;
			}
			System.out.println(id);
		}
	}
}

Measured memory_bytes: 20216
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

graph = [[] for _ in range(N)]
for _ in range(M):
	A, B = MAP()
	graph[A-1].append(B-1)
	graph[B-1].append(A-1)

q = deque()
q.append(0)
ans = [None]*N
ans[0] = 0
while q:
	n = q.popleft()
	for node in graph[n]:
		if ans[node] == None:
			q.append(node)
			ans[node] = n
print("Yes")
for i in range(1, N):
	print(ans[i]+1)


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 3;

void solve(){
    int A, B;
    cin >> A >> B;
    int ans = -1;
    if( 1 <= A && A <= 9 && 1 <= B && B <= 9){
        ans = A * B;
    }

    cout << ans << endl;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <vector>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define Rep(i,n) for(ll i = 0; i <= n; ++i)
#define yes "yes"
#define Yes "Yes"
#define no "no"
#define No "No"

namespace mydef
{
  void say(string some){
    cout << some << "\n";
  }
} // namespace mydef
using namespace mydef;
typedef long long ll;
const int INF = 1001001001;

//ここからいじる

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  n %= 10;
  if(n == 3){
    cout << "bon" << endl;
  }
  else if (n == 0 || n == 1 || n == 6 || n == 8)
  {
    cout << "pon" << endl;
  }
  else
  {
    say("hon");
  }
  
  
  

  return 0;
}

Measured memory_bytes: 3652
a,b,c,d=map(int,input().split());m=998244353;D=[[0]*(d+1)for _ in range(c+1)];D[a][b]=1
for i in range(a,c+1):
 for j in range(b,d+1):
  D[i][j]+=(D[i][j-1]*i+D[i-1][j]*j-D[i-1][j-1]*(i-1)*(j-1))%m
print(D[c][d])

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

int main(){
    int h,w;
    cin >> h >> w;
    char c[h+2][w+2];
    for(int H = 0;H < h+2;H++){
        for(int W = 0;W < w+2;W++)c[H][W] = '#';
    }
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++)cin >> c[i+1][j+1];
    }
    for(int i = 0;i < h+2;i++){
        for(int j = 0;j < w+2;j++)cout << c[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//
 
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << 0, 0;
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)
 
const long long MXN = 1e6 + 200;
const long long MNN = 1e4 + 520;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;

int n, a[17][17], pw[20];
llong dp[(1 << 16)];

void rec(int i, vector<int> &not_taken, int mask, int first, int second){
    if(i == not_taken.size()){
        dp[mask] = max(dp[mask], dp[first] + dp[second]);
        return ;
    }
    rec(i + 1, not_taken, mask, first + (1 << not_taken[i]), second);
    rec(i + 1, not_taken, mask, first, second + (1 << not_taken[i]));
}

int main (){
    ios;
    cin >> n;
    pw[0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
        if(i > 0) pw[i] = pw[i - 1] * 3;
    }
    pw[n] = pw[n - 1] * 3;
    for(int mask = 1; mask < (1 << n); mask++){
        llong ans = 0;
        for(int i = 0; i < n; i++){
            if((mask & (1 << i)) == 0) continue;
            for(int j = i + 1; j < n; j++){
                if(mask & (1 << j)){
                    ans += a[i][j];
                }
            }
        }
        dp[mask] = ans;
    }
    for(int i = 0; i < (1 << n); i++){
        vector<int> not_taken;
        for(int j = 0; j < n; j++){
            if((i & (1 << j))){
                not_taken.pb(j);
            }
        }
        rec(0, not_taken, i, 0, 0);
    }
    cout << dp[(1 << n) - 1];
}

//for(int i = 0; i < pw[n]; i++){
//    llong a = 0, b = 0;
//    llong ones = 0, twos = 0;
//    int x = i;
//    int j = 0;
//    while(x != 0){
//        int lol = x % 3;
//        x /= 3;
//        if(lol == 0) continue;
//        if(lol == 1){
//            a += pw[j] * lol;
//        }else if(lol == 2){
//            b += pw[j] * lol;
//        }
//        ones += 1 * pw[j];
//        twos += 2 * pw[j];
//        j++;
//    }
//    llong ans = dp[a] + dp[b];
//    dp[ones] = dp[twos] = max(max(dp[ones], dp[twos]), ans);
//}
//cout << dp[pw[n] - 1];


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
	int n;
	cin >> n;
	vector<double> v(n);
	rep(i, n) cin >> v[i];

	SORT(v);
	for(int i = 0; i < n - 1; i++){
		v[i + 1] = (v[i] + v[i + 1]) / 2;
	}
	cout << v[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MAXN=200010;
int pre[MAXN],r[MAXN];
int main(){
	memset(pre,127,sizeof(pre));
	int n,ans=-INF;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&r[i]);
		pre[i]=min(pre[i-1],r[i]);
	}
	for(int i=1;i<n;i++){
		ans=max(ans,r[i+1]-pre[i]);
	}
	printf("%d\n",ans);
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, K;
  cin >> N >> K;
  int i = 1;
  int ans = 0;
  while(true){
    ans++;
    i += K-1;
    if(i >= N){
      cout << ans <<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    string s;
    cin>>s;
    int num1=(s[0]-'0')*10+(s[1]-'0');
    int num2=(s[2]-'0')*10+(s[3]-'0');
    if(num1>=1&&num1<=12&&num2>=1&&num2<=12){
        out("AMBIGUOUS");
    }else if(num1>=1&&num1<=12){
        out("MMYY");
    }else if(num2>=1&&num2<=12){
        out("YYMM");
    }else{
        out("NA");
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    int i, j;
    scanf("%d", &n);
    
    for(i=0; i<100; i++){
        for(j=0; j<100; j++){
            if(n - 4*i - 7*j == 0){
                printf("Yes\n");
                
                return 0;
            }
        }
    }
    printf("No\n");
    
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		if (n <= 111) {
			System.out.println("111");
		} else if (n <= 222){
			System.out.println("222");
		} else if (n <= 333){
			System.out.println("333");
		} else if (n <= 444){
			System.out.println("444");
		} else if (n <= 555){
			System.out.println("555");
		} else if (n <= 666){
			System.out.println("666");
		} else if (n <= 777){
			System.out.println("777");
		} else if (n <= 888){
			System.out.println("888");
		} else {
			System.out.println("999");
		}

	}
}

Measured memory_bytes: 23764
N,M=(int(x) for x in input().split())

A = list(map(int, input().split()))

list.sort(A,reverse = True)

s=float(sum(A)/(4*M))
check=0
for i in range(0, M):
    if A[i]<s:
        check=1

if check ==1:
    print('No')
else:
    print('Yes')

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

using namespace std;
const double pi=3.14159265359;
double x[maxn],y[maxn],a[maxn],ans,p,q;
int n;

int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%lf%lf",&x[i],&y[i]);
    for (int i=0;i<n;i++)
    {
        ans=0;
        for (int j=0;j<n;j++) if (i!=j) a[j]=atan2(x[j]-x[i],y[j]-y[i]);
        p=pi; q=-pi; for (int j=0;j<n;j++) if (i!=j) p=min(p,a[j]),q=max(q,a[j]);
        if (q-p<pi) ans=pi-(q-p);
        for (int j=0;j<n;j++) if (i!=j&&a[j]<0) a[j]+=pi*2;
        p=pi*2; q=0; for (int j=0;j<n;j++) if (i!=j) p=min(p,a[j]),q=max(q,a[j]);
        if (q-p<pi) ans=pi-(q-p);
        printf("%.10f\n",ans/pi/2.0);
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

func main() {
	n := nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	prev := a[0]
	for i := 1; i < n; i++ {
		if a[i]-prev > 0 {
			prev = a[i] - 1
		} else if a[i] == prev {
			continue
		} else {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 4096
def main():
    from heapq import heappush, heappop

    INF = 1 << 60
    MX_AG = 2500

    N, M, S = map(int, input().split())
    S = min(S, MX_AG)  # それ以上のAgは不要

    g = tuple(set() for _ in range(N))
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        g[u].add((v, a, b))
        g[v].add((u, a, b))

    exchange = []
    for _ in range(N):
        c, d = map(int, input().split())
        exchange.append((c, d))

    h = [(0, S, 0)]

    time = [[INF] * (MX_AG + 1) for _ in range(N)]
    time[0][S] = 0
    # time[location][r_Ag]:=minimum_time_to_reach

    while h:
        t, ag, loc = heappop(h)
        for to, fare, dt in g[loc]:
            n_Ag = ag - fare
            if n_Ag < 0: continue
            cf = time[to][n_Ag]
            n_time = t + dt
            if cf <= n_time: continue
            time[to][n_Ag] = n_time
            heappush(h, (n_time, n_Ag, to))

        e_time = t + exchange[loc][1]
        e_Ag = ag + exchange[loc][0]
        if e_Ag > MX_AG: continue
        cf = time[loc][e_Ag]
        if cf <= e_time: continue
        time[loc][e_Ag] = e_time
        heappush(h, (e_time, e_Ag, loc))

    ans = (min(time[to]) for to in range(1, N))

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 24092
// Contest: AtCoder Beginner Contest 155 (https://atcoder.jp/contests/abc155)
// Problem: B: Papers, Please (https://atcoder.jp/contests/abc155/tasks/abc155_b)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n; cin >> n;
    bool app = true;
    rep(_, n) {
        int ai; cin >> ai;
        app &= (ai % 2 != 0 || ai % 3 == 0 || ai % 5 == 0);
    }

    cout << (app ? "APPROVED\n" : "DENIED\n");
    return 0;
}

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  vector<int> s;
  void dfs(int now, int left, ostream& out)
  {
    if(now == 0) {
      for (int i = 0; i + 1 < s.size(); i++) {
        out << s[i] << " ";
      }
      out << s.back() << "\n";
      return;
    }
    for (int i = min(now, left); i > 0; i--) {
      s.push_back(i);
      dfs(now - i, i, out);
      s.pop_back();
    }
  }
  void solve(std::istream& in, std::ostream& out)
  {
    int n;
    while (in >> n && n) {
      dfs(n, n, out);
    }
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}

Measured memory_bytes: 3128
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	int card[5];
	while(1){
		rep(i, 5){
			if(scanf("%d,", &card[i]) == EOF)
				return 0;
		}
		
		sort(card, card+5);

		int cnt[4] = {0};
		rep(i, 5){
			cnt[0]++;
			int j=1;
			for(j=1; i+j<5 && card[i+j]==card[i]; ++j){
				cnt[j-1]--;
				cnt[j]++;
			}
			i += j-1;
		}
		if(cnt[3])
			puts("four card");
		else if(cnt[2] && cnt[1])
			puts("full house");
		else if(cnt[0]==5 && (card[4]-card[0]==4 || (card[0]==1 && card[1]==10)))
			puts("straight");
		else if(cnt[2])
			puts("three card");
		else if(cnt[1] == 2)
			puts("two pair");
		else if(cnt[1])
			puts("one pair");
		else
			puts("null");
	}
}

Measured memory_bytes: 0
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def cycle1(a, m):
    x = a % m
    i = 1
    while x != 1:
        x = a * x % m
        i += 1
    return i


def lcm2(m, n):
    # assert m >= n
    while n:
        m, n = n, m % n
    return m


def gcd3(m, n, o):
    # assert m >= n >= o
    g1 = m * n // lcm2(m, n)
    g2 = n * o // lcm2(n, o)
    if g1 > g2:
        return g1 * g2 // lcm2(g1, g2)
    return g1 * g2 // lcm2(g2, g1)


def count_cycle(a1, m1, a2, m2, a3, m3):
    cs = [cycle1(a1, m1), cycle1(a2, m2), cycle1(a3, m3)]
    cs.sort(reverse=True)
    return gcd3(*cs)


def main(readline=stdin.readline):
    while 1:
        data = [int(s) for s in readline().split()]
        if not data[0]:
            exit()
        print(count_cycle(*data))


if __name__ == '__main__':
    main()

Measured memory_bytes: 4260
#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int s, min_s = 500, max_s = 0;

        for (int i = 0; i < n; ++i) {
            int sum = 0;
            for (int j = 0; j < 5; ++j) {
                cin >> s;
                sum += s;
            }
            min_s = min(min_s, sum);
            max_s = max(max_s, sum);
        }
        cout << max_s << " " << min_s << endl;
    }

    return 0;
}

Measured memory_bytes: 1160