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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  
  if ( A.at(A.size()-1) == B.at(0) && B.at(B.size()-1) == C.at(0) ) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


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

ll knapsack(int* v,int* w,int W,int n){
    ll dp[n+1][W+1];
    for(int i=0;i<=W;i++){
        dp[0][i] = 0;
    }
    for(int i=0;i<=n;i++){
        dp[i][0] = 0;
    }
    for(int i=1;i<=n;i++){
        for(int wt=0;wt<=W;wt++){
            dp[i][wt] = dp[i-1][wt];
            if(w[i-1]<=wt){
                dp[i][wt] = max(dp[i][wt],v[i-1] + dp[i-1][wt - w[i-1]]);
            }
        }
    }
    return dp[n][W];
}

int main(){
    int n,W;
    cin>>n>>W;
    int v[n],w[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<knapsack(v,w,W,n);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b;
  cin >> a >> b;

  int ans;
  if (a > b)
    ans = a - 1;
  else
    ans = a;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    long long n,i,j;
    long long ans=0;
    cin>>n;
  	long long a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ans+=a[n-1];
    j=n-2;
    for(i=n-3;i>=0;)
    {
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      j--;
    }
    cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long long n, a, b;
	cin>>n>>a>>b;
	long long k = n / (a + b);
	long long rem = min(n % (a + b), a);
	long long ans = a * k + rem;
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 105

int H,W;
char input[SIZE][SIZE],table[SIZE][SIZE];


int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){

		scanf("%s",input[row]);
	}

	for(int row = 0; row <= H+1; row++){
		for(int col = 0; col <= W+1; col++){

			table[row][col] = '#';
		}
	}

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			table[row+1][col+1] = input[row][col];
		}
	}

	for(int row = 0; row <= H+1; row++){
		for(int col = 0; col <= W+1; col++){
			printf("%c",table[row][col]);
		}
		printf("\n");
	}


	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

// 素因数分解
/*
 * [2]-> 5, [3] -> 5のとき N = 2^5 * 3^5
 */
template<typename T>
map<T, long long> factorize(T x) {
  map<T, long long> res;
  for (long long i = 2; i * i <= x; ++i) {
    while (x % i == 0) {
      x /= i;
      res[i] += 1;
    }
  }
  if (x != 1) res[x]++;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> primes;
  auto f = factorize(n);
  for (auto itr : f) {
    ll cpy = itr.first;
    while (cpy <= n) {
      primes.push_back(cpy);
      cpy *= itr.first;
    }
  }

  sorti(primes);
  ll ans = 0;
  for (auto itr : primes) {
    // cout << itr << endl;
    if (n % itr == 0) {
      ans += 1;
      n /= itr;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3644
use std::cmp::*;
use std::collections::BTreeSet;
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}

#[allow(dead_code)]
fn read_vector<T: FromStr>(number: i32) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}

fn main() {
    let n: i32 = read();
    let mut sum = 0;
    for i in 1..=n {
        for j in 1..=n {
            let g = num::integer::gcd(i, j);
            if g != 1 {
                for k in 1..=n {
                    sum += num::integer::gcd(g, k);
                }
            } else {
                sum += n;
            }
        }
    }
    println!("{}", sum)
}


Measured memory_bytes: 2140
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int e = a*b;
	int f = c*d;
	cout << (e < f ? f : e);

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
    x=0; char c=getchar(); int f=1;
    while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
    while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=(1<<18)+10,mod=998244353;
int Pow(int x,int y) {
    int res=1;
    while(y) {
        if(y&1) res=res*(ll)x%mod;
        x=x*(ll)x%mod,y>>=1;
    }
    return res;
}
int A[N],B[N],C[N];
int m,n;
void FWT(int *A,int f) {
    for(int l=1;l<n;l<<=1)
        for(int p=l<<1,i=0;i<n;i+=p)
            for(int j=0;j<l;++j) {
                int t1=A[i+j],t2=A[i+l+j];
                A[i+j]=(t1+t2)%mod;
                A[i+l+j]=(t1-t2+mod)%mod;
            }
    if(f==1) {
        int inv=Pow(n,mod-2);
        for(int i=0;i<n;++i) A[i]=A[i]*(ll)inv%mod;
    }
}
int main() {
    rd(m); n=(1<<m);
    int sum=0;
    for(int i=0;i<n;++i)
        rd(A[i]),sum+=A[i];
    sum=Pow(sum,mod-2);
    for(int i=0;i<n;++i)
        A[i]=A[i]*(ll)sum%mod;
    A[0]=(A[0]-1+mod)%mod;
    FWT(A,0);
//  for(int i=0;i<n;++i) printf("%d ",A[i]); puts("");
    B[0]=n-1;
    for(int i=1;i<n;++i)
        B[i]=mod-1;
    FWT(B,0);
    C[0]=0;
    for(int i=1;i<n;++i)
        C[i]=B[i]*(ll)Pow(A[i],mod-2)%mod;
    FWT(C,1);
    int tmp=C[0];
    for(int i=0;i<n;++i) C[i]=(C[i]-tmp+mod)%mod;
    for(int i=0;i<n;++i) printf("%d\n",C[i]);
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
//int dx[] = {0, 0, -1, 1};
//int dy[] = {1, -1, 0, 0};

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

    int x1, y1, x2, y2;
    cin >> x1 >> y1  >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3=0,x4=0,y3=0,y4=0;
    x3 = x2 - dy;
    x4 = x3 - dx;
    y3 = y2 + dx;
    y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 <<endl;
    return 0;
}


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

int main() {
	int N, M; cin >> N >> M;
	int k[20], s[20][20], p[20];
	int a[20];
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}
	int sum = 0;
	for (int i = 0; i < pow(2, N); i++) {
		for (int j = 0; j < N; j++) {
			if ((i >> j) % 2 == 1) {
				a[j+1] = 1;
			}
			else {
				a[j+1] = 0;
			}
		}
		int z = 0;
		for (int l = 0; l < M; l++) {
			int c = 0;
			for (int m = 0; m < k[l]; m++) {
				if (a[s[l][m]] == 1)c++;
			}
			if (c % 2 != p[l]) z = 1;
		}
		if (z == 0) sum++;
	}
	cout << sum;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,m;
    char z;
    int i,j;
    int flg;
    while(1){
        char a[100] = {0},b[100] = {0};
        char all[4] = {0};
        char ans[1000000] = {0};
        scanf("%s",&all);
        n = atoi(all);
        if(n == 0) break;
        //変換表入力
        for(i = 0; i < n; i++){
            scanf(" %[^\n]",all);
            a[i] = all[0];
            b[i] = all[2];
        }
        scanf("%d",&m);
        for(i = 0; i < m; i++){
            scanf(" %c",&z);
            for(j = 0; j < n; j++){
                if(z == a[j]){
                    flg = j;
                    break;
                }
                else flg = -1;
            }
            if(flg == -1) ans[i] = z;
            else ans[i] = b[flg];
        }
        printf("%s\n",ans);
    }

    return 0;
}

Measured memory_bytes: 1560
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var watched = new bool[n];
        var to = new int[n];
        var mo = new List<int>[32];
        for (int i = 1; i <= 31; i++) mo[i] = new List<int>();
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            for (int j = a; j <= b; j++) mo[j].Add(i);
            to[i] = b;
        }
        var ret = getAns(mo, watched, to);
        Console.WriteLine(100 * ret + 50 * (31 - ret));
    }
    public static int getAns(List<int>[] mo, bool[] watched, int[] to)
    {
        var count = 0;
        for (int i = 1; i <= 31; i++)
        {
            var wlist = new List<int>();
            foreach (var x in mo[i])
                if (!watched[x]) wlist.Add(x);
            if (wlist.Count() == 1) { count++; watched[wlist[0]] = true; }
            else if (wlist.Count() > 1)
            {
                var a = getMovie(wlist, to);
                count++;
                watched[a] = true;
            }
        }
        return count;
    }
    public static int getMovie(List<int> a, int[] to)
    {
        var tomin = to[a[0]];
        var ret = a[0];
        for (int i = 1; i < a.Count(); i++)
            if (to[a[i]] < tomin) { tomin = to[a[i]]; ret = a[i]; }
        return ret;
    }
}


Measured memory_bytes: 9580
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    ll N, D;
    cin >> N >> D;
    ll D2 = D * D;
    ll ans = 0;
    REP (i, N) {
        ll x, y;
        cin >> x >> y;
        if (D2 >= x * x + y * y) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;

            s = Console.ReadLine();

            char[] cs = s.ToCharArray();
           
            cs[3] = '8';

            Console.WriteLine(cs);

            Console.ReadKey();

        }
    }
}

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

int main()
{
    int n;

    cin >> n;

    string colorStr = "";
    int rCount = 0;
    int wCount = 0;
    for (int i = 0; i < n; i++)
    {
        char color;
        cin >> color;
        colorStr += color;

        if (color == 'R')
        {
            rCount++;
        }
        else
        {
            wCount++;
        }
    }

    int ans = 0;
    for (int i = 0; i < rCount; i++)
    {
        if (colorStr[i] == 'W')
        {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

void discount_fare()
{
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << "\n";
}


void A_114()
{
  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES\n";
  else cout << "NO\n";
}


void christmas_eve_eve_eve()
{
  int d;
  cin >> d;

  if (d == 25) cout << "Christmas\n";
  else if (d == 24) cout << "Christmas Eve\n";
  if (d == 23) cout << "Christmas Eve Eve\n";
  if (d == 22) cout << "Christmas Eve Eve Eve\n";
}


void right_triangle()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << a * b / 2 << "\n";
}


void entrance_examination()
{
  int t, x;
  cin >> t >> x;

  cout << (double)t / (double)x << "\n";
}


void A_118()
{
  int a, b;
  cin >> a >> b;

  if (b % a == 0) cout << a + b << "\n";
  else cout << b - a << "\n";
}


void still_TBD()
{
  string s;
  cin >> s;

  if (s[5] == '1' || s[6] >= '5') cout << "TBD\n";
  else cout << "Heisei\n";
}


void favorite_sound()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << min(b / a, c) << "\n";
}


void atcoder_beginner_contest111()
{
  int n;
  cin >> n;

  if (n % 111 == 0) cout << n << "\n";
  else
  {
    int a = n / 111;
    ++a;
    cout << a * 111 << "\n";
  }
}


void time_limit_exceeded()
{
  int N, T;
  cin >> N >> T;

  int ans = 1001;
  for (int i = 0; i < N; ++i)
  {
    int c, t;
    cin >> c >> t;

    if (t <= T && c < ans) ans = c;
  }
  if (ans == 1001) cout << "TLE\n";
  else cout << ans << "\n";
}


void palace()
{
  int n, t, a;
  cin >> n >> t >> a;

  double d_min = 1000;
  int ans = 0;
  for (int i = 1; i <= n; ++i)
  {
    int h;
    cin >> h;
    double d = (t - h * 0.006) - a;
    if (d < 0) d *= -1;
    if (d < d_min)
    {
      d_min = d;
      ans = i;
    }
  }
  cout << ans << "\n";
}


void B_114()
{
  string s;
  cin >> s;

  int ans = 1000;
  for (int i = 0; i < s.size() - 2;++i)
  {
    int now_s = stoi(s.substr(i,3));
    ans = min(ans, abs(753 - now_s));
  }
  cout << ans << "\n";
}


void christmas_eve_eve()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];

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

  int v_sum = 0;
  for (int i = 0; i < n; ++i)
  {
    if (i == n - 1) v_sum += p[i] / 2;
    else v_sum += p[i];
  }
  cout << v_sum << "\n";
}



int main()
{
  //atcoder_beginner_contest999();
  //programming_education();
  //discount_fare();
  //A_114();
  //christmas_eve_eve_eve();
  //right_triangle();
  //entrance_examination();
  //A_118();
  //still_TBD();
  //favorite_sound();

  //atcoder_beginner_contest111();
  //time_limit_exceeded();
  //palace();
  //B_114();
  christmas_eve_eve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios_base::sync_with_stdio(false);
   int n,k,x,ans=0;
   cin >> n >> k;
   for(int i=0;i<n;i++){
       cin >> x;
       if(x > k-x){
           ans+=(k-x)*2;
       }
       else{
           ans+=x*2;
       }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
// Created by Nikolay Budin

#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>
#define ff first
#define ss second
#define szof(x) ((int)x.size())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }


void solve() {
	int n;
	cin >> n;
	vector<int> inp;
	for (int i = 0; i < n; ++i) {
		int num;
		cin >> num;
		--num;
		inp.push_back(num);
	}

	vector<int> ans;
	while (szof(inp)) {
		bool changed = false;
		for (int i = szof(inp) - 1; i >= 0; --i) {
			if (inp[i] == i) {
				ans.push_back(i);
				inp.erase(inp.begin() + i);
				changed = true;
				break;
			}
		}
		if (!changed) {
			break;
		}
	}

	if (szof(inp)) {
		cout << "-1\n";
	} else {
		reverse(ans.begin(), ans.end());
		for (int num : ans) {
			cout << num + 1 << "\n";
		}
	}
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int maxn = 1e3 + 5;
const int inf = 1e9 + 7;
char G[maxn][maxn];
bool vis[maxn][maxn];
long long dp[maxn][maxn];
long long step ;
int n , m;
long long dfs(int x , int y){
	if(vis[x][y])return dp[x][y] %inf;
	if(x == n && y == m - 1)return 1;
	vis[x][y] = 1;
	if(G[x + 1][y] == '.') dp[x][y] += dfs(x + 1 , y);
	if(G[x][y + 1] == '.') dp[x][y] += dfs(x , y + 1);
	return dp[x][y] %inf;
}
int main(){
	int ans;
	scanf("%d%d ",&n,&m);
	for(int i = 1;i <= n;i++){
		scanf("%s",G[i]);
	}
	ans = dfs(1 , 0) %inf;
	printf("%d\n",ans);
return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";

const int INF = 1001001001;

using namespace std;


int main() {

    string s;
    cin >> s;
    
    bool is = true;
    if (s[0] == s[1] && s[1] == s[2]) is = false;

    string ans = "No";
    if (is) ans = "Yes";
    AA(ans);
}

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

int main()
{
    int H, W;

    while (true)
    {
        cin >> H >> W;
        if (H == 0 && W == 0)
        {
            break;
        }

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if ((i + j) % 2 == 0)
                {
                    cout << "#";
                }
                else
                {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3112
//問題URL
//

//解き方メモ
//
    
#include<iostream>
#include<string>
using namespace std;

int main(){
  string c[2];

  //C入力
  for(int i=0;i<2;i++){
    cin >> c[i];
  }

  bool f = true;
  for(int i=0;i<3;i++){
    if(c[0][i] != c[1][2-i]){
      f = false;
      break;
    }
  }

  if(f){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

int main() {
    int N;
    cin >> N;

    cout << N / 3 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define PI 3.14159265358979323846
#define inf 200000000
#define N 81
// #define double long double

int32_t main()
{
    IOS;

    int n;
    cin >> n;
    n--;
    cout << (n * (n + 1)) / 2;
    
}   
 
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

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

const ll mod = 1e9 + 7;

vector<vector<ll>> g;
vector<ll> ret;
vector<ll> a;
vector<bool> used;

void dfs(vector<ll>& cur, ll pos)
{
    if (used[pos])
    {
        return;
    }
    used[pos] = 1;
    auto itr = lower_bound(cur.begin(), cur.end(), a[pos]);
    ll tmp = *itr;
    *itr = a[pos];
    auto p = lower_bound(cur.begin(), cur.end(), mod);
    ret[pos] = p - cur.begin();
    
    for (int i = 0; i < g[pos].size(); ++i)
    {
        dfs(cur, g[pos][i]);
    }
    *itr = tmp;
    
    return;
}

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    
    a = vector<ll>(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    g = vector<vector<ll>>(n, vector<ll>());
    ret = vector<ll>(n);
    used = vector<bool>(n);
    for (int i = 0; i < n - 1; ++i)
    {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<ll> start(n, mod + 1ll);
    dfs(start, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cout << ret[i] << endl;
    }
    

    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int alice=0, bob=0;
  for(int i=0; i<K; i++){
      alice+=a.at(i);
  }
  cout << alice << endl;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
template<class T> using priority_queue_reverse = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = 1'000'000'000LL + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
vector<string> split(const string &str, const char delemiter) {vector<string> res;stringstream ss(str);string buffer; while( getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

vector<pair<char,long long>> Rarts(string S){
	char ch = S[0];
	int cnt = 1;
	vector<pair<char,long long>> res;
 	for(int i = 1; i < S.size(); ++i){
		 if(S[i]==ch) {
			 cnt++;
		 }
		 else{
			 res.push_back({ch,cnt});
			 ch = S[i];
			 cnt = 1;
		 }
	}
	res.push_back({ch,cnt});
	return res;
}

//verify https://atcoder.jp/contests/agc039/tasks/agc039_a


int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string d;
    for(int i = 0; i < N; ++i) {
        int l,r; cin >> l >> r;
        d.push_back(l==r?'1':'0');
    }
    auto r = Rarts(d);
    for(auto e:r) corner(e.first == '1' && e.second >= 3,"Yes");
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3656
<?php
    fscanf(STDIN,"%d%d",$N,$M);
    $info = array();
    for($i=0;$i<$M;$i++){
        $line = trim(fgets(STDIN));
        list($s,$g) = array_map('intval',explode(" ",$line));
        $info[$s][] = $g;
        $info[$g][] = $s;
    }
    //全頂点を未訪問状態にする。－1は未訪問状態で0以上になると距離を示す
    $dist = array_fill(1,$N,-1);
    //頂点がどこから探査されたものなのかを調べる。
    $dist_x = array_fill(1,$N,-1);
    //スタートは1から始める
    $dist[1] = 0;
    //幅優先探索特有のキュー
    $queue = new SplQueue();
    //入口が1なので１をキューに
    $queue->enqueue(1);
    //キューが空になるまで
    while(!$queue->isEmpty()){
        $v = $queue->dequeue();
        //幅優先探索開始
        foreach($info[$v] as $value){
            if($dist[$value] != -1)continue;//到達済みは探索しない
            $dist_x[$value] = $v;
            //距離に重みがないのでプラス1でいい
            $dist[$value] = $dist[$v]+1;
            $queue->push($value);
        }
    }
    //一個でも$distがー1ならば部屋1からたどり着けない
    if(in_array(-1,$dist)){
        echo "No\n";
        exit;
    }else{
        echo "Yes\n"; 
    }
    
    for($h=2;$h<=array_key_last($dist_x);$h++){
        echo $dist_x[$h]."\n";
    }
?>

Measured memory_bytes: 69796
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector<int> s(m),p(m);
	rep(i,m){
		int k;
		cin >> k;
		rep(j,k){
			int a;
			cin >> a;
			s[i] |= (1 << (a-1));
		}
	}
	rep(i,m){
		cin >> p[i];
	}

	int cnt = 0;

	for(int bit = 0;bit < (1 << n);++bit){
		rep(i,m){
			if(__builtin_popcount(bit & s[i]) % 2 != p[i]) goto EXIT;
		}
		++cnt;
		EXIT:;
	}

	cout << cnt << '\n';

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int x1 = scan.nextInt();
		int y1 = scan.nextInt();
		int x2 = scan.nextInt();
		int y2 = scan.nextInt();
		
		
		int x3 = x2 + (y1 - y2);
		int y3 = y2 - (x1 - x2);
		
		int x4 = x1 - (y2 - y1);
		int y4 = y1 + (x2 - x1);
		
		System.out.println(x3+" "+y3+" "+x4+" "+y4);
		
	}
}


Measured memory_bytes: 25300
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            int X = in.nextInt();

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


Measured memory_bytes: 23636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();

		int n = sc.nextInt();
		System.out.println((n == 0) ? "1" : "0");
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 32824
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, K: int):
    def f(k):
        return ((N * k) % MOD - (k * k) % MOD + k + 1) % MOD
    ans = 1
    for k in range(K, N+1):
        ans = (ans + f(k)) % MOD
    return ans


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(N, K))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return true;}return false;}

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// CHAR_MAX  = 127
// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


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

    string s = to_string(n);
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 3100
# coding: utf-8


def main():
    N = int(input())
    ans = 'Yes'
    t, x, y = 0, 0, 0
    for _ in range(N):
        nt, nx, ny = map(int, input().split())
        d = abs(x - nx) + abs(y - ny)
        if d > nt - t or (nt - t - d) % 2 != 0:
            ans = 'No'
            break
        t, x, y = nt, nx, ny

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string s;
    cin >> s;
    int ans=0;
    rep(i,3)
    {
        if(s[i]=='1')++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    bool good = true;
    for (int i = 1; i < s.size() && good == true; i++) {
        if (s[i] == s[i-1]) good = false;
    }

    cout << (good ? "Good" : "Bad") << endl;
}

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

int main(){
  ll N;cin>>N;
  vector<ll> v(5,0);
  rep(i,N){
    string s;cin>>s;
    if(s[0]=='M') v[0]++;
    if(s[0]=='A') v[1]++;
    if(s[0]=='R') v[2]++;
    if(s[0]=='C') v[3]++;
    if(s[0]=='H') v[4]++;
  }
  ll ans=0;
  for(int i=0;i<5;++i){
    for(int j=1;j<5;++j){
      for(int k=2;k<5;++k){
        if(i>=j || j>=k) continue;
        else ans += v[i]*v[j]*v[k];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 1e5 + 6;
const int M = 1e9+7;
int A[N];
string s;
int n , d;
int dp[N][102][2];

int alpha(int id , int sum , int ok)
{
	if(id == n)return (sum == 0);
	int &abs = dp[id][sum][ok];
	if(abs != -1)return abs;
	int ans = 0;

	int k = s[id]-'0';
	if(ok)k = 9;

	loop(i,0,k+1)
	{
		if(i < k)
		{
			int nsum = (sum + i)%d;
			ans += alpha(id+1 , nsum , 1);
			ans %= M;
		}
		else
		{
			int nsum = (sum + i)%d;
			ans += alpha(id+1 , nsum , ok);
			ans %= M;
		}
	}

	return abs = ans;
}


void solve()
{	
	cin >> s >> d;
	n = s.length();
	mset(dp,-1);
	int ans = alpha(0,0,0)-1;
	if(ans == -1)ans = M-1;
	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 163788
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int N, M, X, Y;
	int x[100], y[100];
	int min = 100, max = -100;

	cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		if (x[i] > max)max = x[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> y[i];
		if (y[i] < min)min = y[i];
	}
	if (max < min&&max<Y&&min>X)puts("No War");
	else puts("War");


	return(0);
}

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define PB push_back
#define MP make_pair
#define tt ll TT; cin>>TT; while(TT--)
#define F first
#define S second
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;

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

    //tt
    {
        ll n;
        cin>>n;
        vector<pair<ll, ll> > v(n);
        loop(i,0,n) {
            ll temp;
            cin>>temp;
            v[i] = {temp, i};
        }
        sort(all(v));
        ll count = 0, min = INT_MAX;
        loop(i,0,n) {
            if(min>v[i].second) {
                min = v[i].second;
                count++;
            }
        }
        cout<<count<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const int INF = (int)1e9 + 7;
enum { BLOCK = 1, GOAL = 3 };

int w, h, ans;
vector<vector<int>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};

bool exterior(int y, int x) {
    return x < 0 || w <= x || y < 0 || h <= y;
}

int dfs(int cy, int cx, int step) {
    if (step + 1 >= ans) return INF;
    for (int k = 0; k < 4; k++) {
        // 一歩踏み出す
        int ny = cy + dy[k], nx = cx + dx[k];
        if (exterior(ny, nx) || field[ny][nx] == BLOCK) continue;
        while (not exterior(ny, nx)) {
            if (field[ny][nx] == GOAL) return step + 1;
            if (field[ny][nx] == BLOCK) {
                field[ny][nx] = 0;
                ans = min(ans, dfs(ny - dy[k], nx - dx[k], step + 1));
                field[ny][nx] = 1;
                break;
            }
            ny += dy[k]; nx += dx[k];
        }
    }
    return ans;
}

int main() {
    while (cin >> w >> h, w) {
        field.clear(); field.resize(h, vector<int>(w));
        int si, sj, gi, gj;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> field[i][j];
                if (field[i][j] == 2) si = i, sj = j, field[i][j] = 0;
                if (field[i][j] == 3) gi = i, gj = j;
            }
        }
        ans = 11;
        ans = dfs(si, sj, 0);
        cout << (ans > 10 ? -1 : ans) << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    
    int n,d,cnt=0;
    
    cin>>n>>d;
    int mas[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>mas[i][j];
        }
    }
    
    double sum=0;
    for(int i=0;i<n-1;i++){
        for(int k=i+1;k<n;k++){
            for(int j=0;j<d;j++){
                sum += pow(mas[i][j] - mas[k][j], 2);   
            }
            double han=sqrt(sum);
            //cout<<i<<" "<<han<<" "<<sum<<endl;
            if(ceil(han) == floor(han)) cnt++;    
            sum=0;
        }
        
    }
    
    cout<<cnt<<endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x, y, i;
	
	scanf("%d %d", &x, &y);
	
	i = x % y;
	
	while (i != 0){
		x = y;
		y = i;
		i = x % y;
	}
	
	printf("%d\n", y);
	
	return (0);
}

Measured memory_bytes: 592
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;

fn main() {
    input!{
        n: usize,
        ds: [usize; n],
    }
    let mut ds = ds;
    ds.sort();

    let mut cnt = 0;
    let mut last = 0;
    for i in (0..ds.len()).rev() {
        if last != ds[i] {
            cnt += 1;
        }
        last = ds[i];
    }
    println!("{}", cnt);
}


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

#define INF (1<<18)


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

    ll ans = 0;
    rep(i,n) ans += a[i];
    ans -= n;

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
using namespace atcoder;

int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    long long n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << "\n";
  }
}

Measured memory_bytes: 3644
a, b = input().split()
a = int(a)

c = 0
c += a*int(b[0])*100
c += a*int(b[2])*10
c += a*int(b[3])
c = str(c)
if(len(c) < 3):
  print(0)
else:
  print(c[:-2])



Measured memory_bytes: 9184