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

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

int n, a[N5 * 2];

vector < int > v;

int main()
{
    cin >> n;
    forn (i, 1, n)
    {
        cin >> a[i];
    }
    if (n % 2 == 1)
    {
        for (int i = n; i >= 1; i -= 2)
            v.pb(a[i]);
        for (int i = 2; i <= n; i += 2)
            v.pb(a[i]);
    }
    else
    {
        for (int i = n; i >= 2; i -= 2)
            v.pb(a[i]);
        for (int i = 1; i <= n; i += 2)
            v.pb(a[i]);
    }
    fora (x, v)
        cout << x << " ";
}
/*
1
1
1

2
1 2
2 1

3
1 2 3
3 1 2

4
1 2 3 4
4 2 1 3

5
1 2 3 4 5
5 3 1 2 4

6
1 2 3 4 5 6
6 4 2 1 3 5

7
1 2 3 4 5 6 7
7 5 3 1 2 4 6

*/


Measured memory_bytes: 3828
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            long[] x = new long[N], y = new long[N];
            for (var i = 0; i < N; ++i)
            {
                var xy = Sarray();
                x[i] = xy[0];
                y[i] = xy[1];
            }

            var men = long.MaxValue;
            for (var i1 = 0; i1 < N; ++i1)
            {
                for (var i2 = 0; i2 < N; ++i2)
                {
                    for (var i3 = 0; i3 < N; ++i3)
                    {
                        for (var i4 = 0; i4 < N; ++i4)
                        {
                            var xld = Min(x[i4], Min(x[i3], Min(x[i2], x[i1])));
                            var yld = Min(y[i4], Min(y[i3], Min(y[i2], y[i1])));
                            var xru = Max(x[i4], Max(x[i3], Max(x[i2], x[i1])));
                            var yru = Max(y[i4], Max(y[i3], Max(y[i2], y[i1])));
                            var n = 0L;
                            for (var k = 0; k < N; ++k)
                            {
                                if ((xld <= x[k] && x[k] <= xru) &&
                                    (yld <= y[k] && y[k] <= yru))
                                    ++n;
                            }
                            if (K <= n)
                                men = Min(men, (xru - xld) * (yru - yld));
                        }
                    }
                }
            }
            WriteLine(men);
        }
    }
}

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

using namespace std;

long long inf=1000000007;

long long modpow(long long n,long long p,long long mod);

int main(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	long long cnt=0;

	while(a>=b || b>=c){
		if(a>=b){
			b*=2;
		}else{
			c*=2;
		}

		cnt++;
	}

	if(cnt<=k) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

long long modpow(long long n,long long p,long long mod){
	if(p==0) return 1;
	if(p%2==0) return (modpow(n,p/2,mod)*modpow(n,p/2,mod))%mod;
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}


Measured memory_bytes: 3636
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
vector<vii >se(55),se1(55);
int rej[1005][1005];
ll a[1005];
int main(){
	std::ios::sync_with_stdio(false);
	int t;
	t=1;
	while(t--){
		ll n,k,ans=0,val=0,i=0,j,s;
		cin>>n>>k;
		rep(i,n){
			cin>>a[i];
		}
		rep(i,n){
			s=0;
			f(j,i,n){
				s+=a[j];
				rep(val,42){
					if(s&(1LL<<val)){
						se[val].pb(mp(i,j));
					}
					else{
						se1[val].pb(mp(i,j));
					}
				}
			}
		}
		//return 0;
		val=0;
		fd(i,41,0){
			val=0;
			for(j=0;j<se[i].size();j++){
				if(rej[se[i][j].ff][se[i][j].ss]==0){
					val++;
				}
			}
			if(val<k){
				continue;
			}
			else{
				ans+=(1LL<<i);
				for(j=0;j<se1[i].size();j++){
					rej[se1[i][j].ff][se1[i][j].ss]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
} 
	

Measured memory_bytes: 183860
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int r;
    cin>>r;
    if(r<1200)cout<<"ABC"<<endl;
    else if(r<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

ll b;

int main() {
  while (scanf("%lld", &b), b) {
    ll ans = 0, ansx = 0;
    for (ll i = 1; i*i < 2*b; i++) {
      if (2 * b % i == 0) {
        ll j = 2*b / i;
        if (j % 2 == 0 xor i % 2 == 0) {
          ans = i;
          ansx = (j - i - 1) / 2;
        }
      }
    }
    printf("%lld %lld\n", ansx + 1, ans);
  }
}



Measured memory_bytes: 2716
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	cin>>i>>j;
	cout<<i*j<<endl;

}

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

int main()
{
    string s;
    cin>>s;
    int n = s.length();
    int * ans = new int[n]();
    int* rmoves = new int[n]();
    int* lmoves = new int[n]();

    int curr =0;
    for(int i=n-1;i>=0;i--)
    {
        if( s[i] == 'R')
        {
            curr++;
            rmoves[i] = curr;
        }
        else curr = 0;
    }
    curr =0;
    for(int i=0;i<n;i++)
    {
        if( s[i] == 'L')
        {
            curr++;
            lmoves[i] = curr;
        }
        else curr = 0;
    }


    for( int i=0;i<n;i++)
    {
        int moves =0;
        if( s[i] == 'L')
        {
            int moves = lmoves[i];
            int index = i-moves;
            if( moves%2 == 0)
            {
                ans[index]++;
            }
            else ans[index+1] ++;
        }
        if( s[i] == 'R')
        {

            moves = rmoves[i];
           int index = i + moves;
            if( moves%2 == 0)
            {
                ans[index]++;
            }
            else ans[index-1] ++;
        }
    }
    for(int i=0;i<n;i++)
    {
        cout<<ans[i] <<" ";

    }

}

Measured memory_bytes: 4932
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    bool ans=true;
   ll n;
   cin>>n;
   vll a(n),b(n);
   vector<pll> p;
   rep(i,n){
       cin>>a.at(i)>>b.at(i);
       p.push_back( pll( b.at(i), a.at(i) ) );
   }
   sort(ALL(p));
   ll pos = 0;
   for ( auto& i: p ){
       pos+=i.second;
       if(pos>i.first){
           ans=false;
           break;
       }
   }
   
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
   
   
}
   



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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    int ans = 0;
    REP2(i, 1, N) {
        string s = to_string(i);
        if (s.size() % 2 == 1) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

if b-a <= 2:
    print(1+k)
    exit()
    
check = 0
ans = 1

while True:
    if check == 0:
        if (k-2) >= a-1:
            k = k-2-(a-1)
            ans -= 1
            ans += b
            check = 1
            continue
        else:
            ans += k
            break
    else:
        if k % 2 == 0:
            s = k//2
            ans -= a * s
            ans += b * s
        else:
            s = k//2
            ans -= a * s
            ans += b * s + 1
    break

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;

int N;
int d[2][100000];
vector<int> v[100000];

int dfs(int x, int y, int w, int z){

    d[z][x] = w;
    for(int i=0; i<v[x].size(); i++){
        if( v[x][i] == y) continue;
        dfs( v[x][i], x, w+1, z);
    }
}

int main (){
    int c1b=0,c2w=0;
    cin >> N;
    for(int i=0; i<N-1; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs( 0, -1, 0, 0);
    dfs( N-1, -1, 0, 1);

    for(int i=0; i<N; i++){
        if ( d[0][i] <= d[1][i] ){
            c1b++;
        } else c2w++;
    }
    cout << (c1b > c2w ? "Fennec" : "Snuke") << endl;
    return 0;
}


Measured memory_bytes: 14336
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

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)*}
    };
}

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)*}
    };
}

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(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {a:usize,b:usize,c:usize,d:usize}
    println! {"{}",
    if a+b > c+d {
        "Left"
    }else if a + b == c+d{
        "Balanced"
    }else{
        "Right"
    }}
}


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

namespace ABC139C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] Hinput = Console.ReadLine().Split(' ');
            int[] H = new int[N+1];
            H[N] = 1000000001;
            int max = 0;
            int temp = 0;
            for(int i = 0; i < N; i++)
            {
                H[i] = int.Parse(Hinput[i]);
            }
            for (int i = 0; i < N; i++)
            {
                if (H[i] >= H[i + 1])
                {
                    temp += 1;
                }
                else
                {
                    if (temp > max)
                    {
                        max = temp;
                    }
                    temp = 0;
                }
            }
            Console.WriteLine(max);
        }
    }
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int A, B, C, K;
        cin >>A >>B >>C >>K;
        int S=0;
        while (B<=A) {
                B +=B;
                S++;
        }
        while (C<=B) {
                C +=C;
                S++;
        }
        if (S<=K)
                cout <<"Yes" <<endl;
        else
                cout <<"No" <<endl;
        return 0;
}

Measured memory_bytes: 3620
"""#D - Not Divisible
N= map(int,input().split())
A= list(map(int,input().split()))"""


#C - Forbidden List
X,N= map(int,input().split())
p= list(map(int,input().split()))
A= list(range(-200,200))
#print(A)
for i in range(N):
    A.remove(p[i])

D = 201
ans = -100
for j in range(len(A)):
    if D > abs(X - A[j]):
        D = abs(X - A[j])
        ans = A[j]

    else:
        pass
print(ans)


Measured memory_bytes: 9208
my ($n) = split(/\s/, <STDIN>);
my (@a) = split(/\s/, <STDIN>);
my ($max, $min) = ($a[0], $a[0]);

for (@a) {
    if ($max < $_) { $max = $_; }
    if ($min > $_) { $min = $_; }
}

print ($max - $min), "\n";


Measured memory_bytes: 384
#include<bits/stdc++.h> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int,int>;

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s.at(i);
  vector<int> dx = {0,1,0,-1};
  vector<int> dy = {1,0,-1,0};
  rep(i,h){
    rep(j,w){
      if( s.at(i).at(j) == '#' ){
        bool ok = false;
        rep(k,4){
          if( i+dy.at(k) >= 0 && i+dy.at(k) < h &&
              j+dx.at(k) >= 0 && j+dx.at(k) < w    ){
            if( s.at(i+dy.at(k)).at(j+dx.at(k)) == '#' ) ok = true;
          }
        }
        if( !ok ){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
cnt=[0]*4
for i in range(N):
    S = input()
    if S=="AC":
        cnt[0]+=1
    elif S=="WA":
        cnt[1]+=1
    elif S=="TLE":
        cnt[2]+=1
    elif S=="RE":
        cnt[3]+=1
print("AC x " + str(cnt[0]))
print("WA x " + str(cnt[1]))
print("TLE x " + str(cnt[2]))
print("RE x " + str(cnt[3]))

Measured memory_bytes: 69908
#include<stdio.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int w,h;
int black[51][51];
int white[51][51];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char map[51][51];
void solve(int y,int x,char c){
    if((c == 'B' && black[y][x]) || (c == 'W' && white[y][x])) return;
    if(c == 'W' && map[y][x]!='W') white[y][x] = 1;
    else if(c == 'B' && map[y][x]!='B') black[y][x] = 1;
    
    rep(i, 4){
        int nx = x + dx[i]; int ny = y + dy[i];
        if(0 <= nx && nx < w && 0 <= ny && ny < h && map[ny][nx] == '.'){
            solve(ny, nx, c);
        }
    }
}
int main(void){
    while(1){
        scanf("%d%d",&w,&h);
        if(w+h==0) break;
        getchar();
        rep(i,h) scanf("%s",map[i]);
        rep(i,h){
            rep(j,w){
                black[i][j]=white[i][j]=0;
            }
        }
        rep(i,h){
            rep(j,w){
                if(map[i][j]=='W'){
                    solve(i,j,'W');
                }else if(map[i][j]=='B'){
                    solve(i,j,'B');
                }
            }
        }
        int bl=0,wh=0;
        rep(i,h){
            rep(j,w){
                if(black[i][j] && !white[i][j]) bl++;
                else if(!black[i][j] && white[i][j]) wh++;
            }
        }
        printf("%d %d\n",bl,wh);
    }
}



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

using namespace std;

typedef unsigned long long ll;

int main() {
	ll n; scanf("%lld",&n);
	ll index=10, cnt=0;
	if (n%2!=0) printf("%d",0);
	else {
		while (index<=n) {
			cnt+=n/index;
			index=index*5;
		}
		printf("%lld",cnt);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll ans = 0,i,j,n,a,b,c;
  	cin>>n;
  	for(a = 1;a <= n;a++)
    {
      	for(b = 1;b <= n;b++)
        {
         	if(a*b >= n)
              break;
          	ans++;
        }
    }
  		
  	cout<<ans<<endl;
  

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

const int MAXN = 1010;
const int MAXK = 1010;
long long P[MAXN][MAXK];

// 分割数 (n: 玉の数, k: 箱の数)
// 前処理時間 O(nk)
// クエリ時間 O(1)
void calcPartition(int n, int k) {
    P[0][0] = 1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 1; j <= k; ++j) {
            P[i][j] = P[i][j - 1];
            if (i - j >= 0)
                P[i][j] = (P[i][j] + P[i - j][j]) % MOD;
        }
    }
}

void _main() {
    int n, k;
    cin >> n >> k;
    calcPartition(n, k);
    cout << P[n][k] << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 11060
h,w = map(int,input().split())
board = [list(input()) for _ in range(h)]
x = (-1,0,1,0,-1,1,-1,1)
y = (0,-1,0,1,-1,-1,1,1)
for i in range(h):
  for j in range(w):
    if board[i][j] == "#":
      continue
    else:
      cnt = 0
      for k in range(8):
        if 0 > i + y[k] or i + y[k] >= h or 0 > j + x[k] or j + x[k] >= w:
          continue
        else:
          if board[i + y[k]][j + x[k]] == "#":
            cnt += 1
      board[i][j] = str(cnt)
for i in range(h):
  print("".join(board[i]))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,m,d,t;
	bool ans = true;
	cin >> n;
	map<int, int>md, mt;
	rep(i, n) {
		cin >> d;
		md[d]++;
	}
	cin >> m;
	rep(i, m) {
		cin >> t;
		mt[t]++;
	}
	for (auto q : mt) {
		if (q.second > md[q.first])ans = false;
	}
	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 22316
program abc170b
      implicit none
      integer::x,y
      integer::a,b

         read *, x,y
         a=4*x-y
         b=y-2*x
         if ( mod(a,2)/=0 .or. mod(b,2)/=0 ) then
            print *, 'No'
            stop
         end if
         a=a/2
         b=b/2
         if ( 0<=a .and. a<200 ) then
            if ( 0<=b .and. b<=49 ) then
               print *, 'Yes'
               stop
            end if
         end if

         print *, 'No'

   end program abc170b

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

using namespace std;
using ll = long long;


int main()
{
    int x, y;
    cin >> x >> y;
    if(y % 2) {
        cout << "No" << endl;
        return 0;
    }
    if(x * 2 <= y && y <= x * 4) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	char b;
	cin >> b;
	if (b == 'A')
		cout << 'T' << endl;
	if (b == 'C')
		cout << 'G' << endl;
	if (b == 'G')
		cout << 'C' << endl;
	if (b == 'T')
		cout << 'A' << endl;
}

Measured memory_bytes: 3596
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

#define POW2(X) (1<<(X))
#define CKBIT(S,X) (((S)&POW2(X))!=0)

template<class T> inline void nlmin(T &a,T b){ a=min(a,b); }
template<class T> inline void nlmax(T &a,T b){ a=max(a,b); }
template<class T> inline T sqr(T x){ return x*x; }
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())

#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(),A.end()
template<class T> int CMP(T a[],const T b[],int n) { return memcmp(a,b,n*sizeof(T)); }
template<class T> void COPY(T a[],const T b[],int n) { memcpy(a,b,n*sizeof(T)); }
template<class T> void SET(T a[],int val,int n) { memset(a,val,n*sizeof(T)); }
//using uint=unsigned int;
typedef long long int64;
//using uint64=unsigned long long;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VII;
// using VD=vector<double>;
const int kmod = 1000000007;


int main() {

	int N;
	while (cin >> N) {
		VII v(N+1, VI(4, 0));
		VII dp(N+1, VI(4, 0));
		FOR (i, 1, N + 1) FOR (j, 1, 4) cin >> v[i][j];

		FOR (j, 1, 4) dp[1][j] = v[1][j];

		FOR (i, 2, N + 1) 
			FOR (j, 1, 4) 
				FOR (k, 1, 4) {
					if(j != k)  nlmax(dp[i][j], dp[i - 1][k] + v[i][j]);
				}

		cout << max({dp[N][1], dp[N][2], dp[N][3]}) << endl;
	}
	return 0;
}

Measured memory_bytes: 11136
mod stdin_reader {
  use std::io::stdin;
  use std::io::Read;
  use std::io::BufRead;

  pub struct StdinReader {
    pub buf: Vec<String>,
    pub cursor: usize,
  }

  pub fn new() -> StdinReader {
    StdinReader::new()
  }

  impl StdinReader {
    pub fn new() -> Self {
      let mut s = String::new();
      let stdin = stdin();
      let buf = stdin
                  .lock()
                  .lines()
                  .flat_map(|line|
                    line
                      .unwrap()
                      .split_whitespace()
                      .map(|s| s.to_string())
                      .collect::<Vec<String>>()
                  ).collect();
      return StdinReader { buf: buf, cursor: 0 }
    }

    pub fn next(&mut self) -> Option<String> {
      let val = self.buf.get(self.cursor).cloned();
      self.cursor += 1;
      return val
    }

    pub fn as_i64(&mut self) -> Option<i64> {
      self.next().and_then(|s| s.parse::<i64>().ok())
    }

    pub fn as_f64(&mut self) -> Option<f64> {
      self.next().and_then(|s| s.parse::<f64>().ok())
    }

    pub fn as_usize(&mut self) -> Option<usize> {
      self.next().and_then(|s| s.parse::<usize>().ok())
    }
  }
}

mod utils {
  pub fn is_int(n: f64) -> bool {
    let trunc = (n.trunc() as i64) as f64;
    return (n - trunc) < 0.0001
  }
}

fn main() {
  // stdout
  use std::io::{stdout, Write, BufWriter};
  let stdout = stdout();
  let mut writer = BufWriter::new(stdout.lock());

  // stdin
  let mut reader = stdin_reader::new();

  let n = reader.as_usize().unwrap();
  let mut a_list = vec![0];
  a_list.extend((0..n).map(|_| reader.as_i64().unwrap()));
  let mut boxes = vec![0; n+1];
  let mut result_rev = vec![];
  for i in (1..(n+1)).rev() {
    let mut bigger_sum: i64 = 0;
    let mut bigger_i = i;
    loop {
      bigger_sum += boxes[bigger_i];
      bigger_i += i;
      if bigger_i > n {
        break;
      }
    }

    if bigger_sum % 2 == a_list[i] {
      // do nothing
    } else {
      boxes[i] = 1;
      result_rev.push(i);
    }
  }

  println!("{}", result_rev.len());
  println!("{}", result_rev.into_iter().rev().map(|i| format!("{}", i)).collect::<Vec<String>>().connect(" "));
}

Measured memory_bytes: 20596
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
   int n,k;
   cin >> n >> k;
   if(k==1)cout << 0 << endl;
   else{
   int x=n-(k-1);
   cout << x-1 << endl;
   }
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

ll c[30];

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

    int h, w;
    cin >> h >> w;
    for(int i=0; i<h; i++){
        string s;
        cin >> s;
        for(int j=0; j<s.size(); j++){
            c[s[j]-'a']++;
        }
    }

    vector<int> need;
    for(int i=0; i<(h+1)/2; i++){
        for(int j=0; j<(w+1)/2; j++){
            if(h%2 == 1 && i == (h+1)/2-1 && w%2 == 1 && j == (w+1)/2-1){
                need.pb(1);
            }else if(h%2 == 1 && i == (h+1)/2-1){
                need.pb(2);
            }else if(w%2 == 1 && j == (w+1)/2-1){
                need.pb(2);
            }else{
                need.pb(4);
            }
        }
    }
    /*
    ll all = 0;
    for(int i=0; i<h/2; i++){
        if(w != 1){
            need.pb(4);
            all += 4;
        }else{
            need.pb(2);
            all += 2;
        }
    }
    for(int i=0; i<(w-2)/2; i++){
        if(h != 1){
            need.pb(4);
            all += 4;
        }else{
            need.pb(2);
            all += 2;
        }
    }
    if(h != 1 && h % 2 == 1){
        if(w != 1){
            need.pb(2);
            all += 2;
        }else{
            need.pb(1);
            all += 1;
        }
    }
    if(w != 1 && w % 2 == 1){
        if(h != 1){
            need.pb(2);
            all += 2;
        }else{
            need.pb(1);
            all += 1;
        }
    }
    if(h*w - all > 0){
        need.pb(h*w - all);
    }
    */

    sort(need.begin(), need.end(), greater<int>());
    /*
    for(int i=0; i<need.size(); i++){
        printf("%d\n", need[i]);
    }
    */

    vector<int> use;
    for(int i=0; i<28; i++){
        if(c[i] > 0){
            use.pb(c[i]);
            //printf("%lld\n", c[i]);
        }
    }

    for(int i=0; i<need.size(); i++){

        bool f = false;
        for(int now=0; now<use.size(); now++){
            //printf("need:%d %d\n", need[i], use[now]);
            if(use[now] >= need[i]){
                //printf("ok:%d %d\n", need[i], use[now]);
                f = true;
                use[now] -= need[i];
                sort(use.begin(), use.end(), greater<int>());
                break;
            }
        }
        if(!f){
            puts("No");
            return 0;
        }
    }

    puts("Yes");

    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		char[] c = new char[4];
		
		List<String> list = new ArrayList<>();
        
        for(int i = 0; i < 4; i++){
		    list.add(String.valueOf(S.charAt(i)));
		}
		
		Set<String> set = new HashSet<>(list);
		List<String> list2 = new ArrayList<>(set);
		
		if(list2.size() == 2){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
        
    }
}

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


int findSumOfDigits(int n)
{
	int sum = 0;
	while (n > 0)
	{
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

int main()
{
	int A,B,res;
	res = 0;
	cin >>A>>B;
	for (int i = A; i <= B; i++)
	{
		int a = i % 10, e = i / 10000 % 10;
		int b = i/10 % 10, d = i / 1000 % 10;
		if (a == e && b == d)
		{
			res++;
		}
	}
	
		cout << res << endl;
	

}


Measured memory_bytes: 256
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.size();i++)
    {
        ans+=s[i]-'0';
    }
    if(ans%9)
    cout<<"No\n";
    else
    cout<<"Yes\n";
}



Measured memory_bytes: 3748
#include <iostream>
#include <math.h>

using namespace std;

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

	long long int nn = (long long int)sqrt(n);
	int ojisan;

	for(long long int i = 1; i <= nn; i++){
		if(n % i == 0)
			ojisan = i;
	}

	long long int ojisan1 = n / ojisan;

//	cout << ojisan << '\n';
	cout << ojisan + ojisan1 - 2;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, m: usize,
        mut ab: [(Usize1, Usize1); m],
    }
    
    ab.sort_by_key(|&(a, b)| (b, a));
    let mut prev = 0;
    let mut ans = 0i64;
    for (a, b) in ab {
        if a < prev {
            continue;
        }
        ans += 1;
        prev = b;
    }
    println!("{}", ans);
}


Measured memory_bytes: 5540
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n, m;
  cin >> n >> m;
  int index = 1;
  rep(i,m){
    index *= 2;
  }
  int ans = (100*(n-m) + 1900*m) * index;
  cout << ans << endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n){
        int a;
        cin >> a;
        a--;
        p[i] = a;
    }
    int cnt=0;
    rep(i,n){
        if(i == p[i]){
            swap(p[i],p[i+1]);
            cnt++;
        }
    
    }
    cout << cnt <<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  string s;
  int k;
  cin >> k >> s;
  if(k < s.size()){
    rep(i, k){
      cout << s[i];
    }
    cout << "...\n";
  } else {
    cout << s << '\n';
  }
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vi a(N);
  bool flag=true;
  rep(i,N) {
    cin >> a[i];
    flag&=!(a[i]%2);
  }
  
  if(flag) cout << "second" << endl;
  else cout << "first" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using Vb = V<bool>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVb = V<Vb>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll h, w; cin >> h >> w;

  set<Pi> S, T;
  rep(i, w) S.emplace(i, 0);
  rep(i, w) T.emplace(0, i);

  Vi ans(h);

  rep(k, h) {
    int a, b; cin >> a >> b;
    --a;

    auto l = S.lower_bound({a, -1});
    auto r = S.lower_bound({b, -1});

    int now = INF;
    for (; l != r;) {
      auto [i, j] = *l;
      chmin(now, j - i + b);
      T.erase({j, i});
      l = S.erase(l);
    }

    if (now < INF && b < w) S.emplace(b, now);
    if (now < INF && b < w) T.emplace(now, b);

    if (T.empty()) ans[k] = -1;
    else ans[k] = k+1 + T.begin()->first;
  }
  
  cout << ans << '\n';
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && b==c) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,x,i,j,p,count=0;
	for(;;){
		cin>>n>>x;
		if(n==0&&x==0){
		break;
		}
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(p=j+1;p<=n;p++){
					if(i+j+p==x){
					count++;
					}
				}
			}
		}
		cout<<count<<endl;
		count=0;
	}
return 0;
}


Measured memory_bytes: 3104
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

ll modminus(ll x, ll y) {
    return (x - y + mod) % mod;
}

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

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

ll divide(ll x, ll y) {
    return multiply(x, power(y, mod - 2));
}

int main() {
    int N;
    cin >> N;
    int T[N], A[N];
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int tmax = 0;
    int tmaxnum = 0;
    for (int i = 0; i < N; i++) {
        if (tmax < T[i]) {
            tmaxnum = i;
            tmax = T[i];
        }
    }
    int amax = 0;
    int amaxnum = N - 1;
    for (int i = N - 1; i >= 0; i--) {
        if (amax < A[i]) {
            amaxnum = i;
            amax = A[i];
        }
    }
    if (tmax != amax || tmaxnum > amaxnum) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    tmax = 0;
    for (int i = 0; i < tmaxnum; i++) {
        if (T[i] > tmax) {
            tmax = T[i];
        } else {
            ans = multiply(ans, tmax);
        }
    }
    for (int i = tmaxnum + 1; i < amaxnum; i++) {
        ans = multiply(ans, amax);
    }
    amax = 0;
    for (int i = N - 1; i > amaxnum; i--) {
        if (A[i] > amax) {
            amax = A[i];
        } else {
            ans = multiply(ans, amax);
        }
    }
    cout << ans << endl;
}


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

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

    int longest = 0;
    for(int i = 0; i < S.size(); i++){
        int cnt = 0;
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            for(int j = i; j < S.size(); j++){
                if(S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T'){
                    cnt++;
                    if(cnt > longest)
                        longest = cnt;                   
                }    
                else
                    break;
                           
            }
        }
    }
    cout << longest << endl;

    return 0;
}

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

int main(void) {
   int n,max = -1000000,min = 10000000;
   long long a,goukei = 0;
   cin >> n;
   for (int i = 0; i < n; i++) {
       cin >> a;
       if (min > a) {
           min = a;
       }
       if (max < a) {
           max = a;
       }
       goukei += a;
   }
   cout << min << " "<< max << " " << goukei << endl;

   return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const ll INF = 1e19;
int main(){
    int n;
    cin >> n;

    vector<long long> sum (n);
    rep(i, n){
        ll a;
        cin >> a;
        if( i == 0 )sum[i] = a;
        else sum[i] = sum[i-1] + a;
    }

    long long res = INF;
    rep(i, n){
        res = min( res , (long long)abs( sum[n-1] - 2 * sum[i] ) );
    }


    cout << res << endl;
}

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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	int ans=1;
	int min=0;
	for(auto& x:a){
		cin>>x;
		if(min==0){
			min=x;
		}else{
			if(min>x){
				min=x;
			}
		}
	}
	vector<int> factor,factor2;
	for(int i=1;i<min;i++){
		if(i*i>min){
			break;
		}
		if(min%i==0){
			factor.push_back(i);
			factor2.push_back(min/i);
		}
	}
	for(int i=factor2.size()-1;i>=0;i--){
		factor.push_back(factor2[i]);
	}
//	for(auto x:factor){
//		cout<<x<<endl;
//	}
	for(int i=factor.size()-1;i>=0;i--){
		int f=factor[i];
		int flag=1;
		for(auto x:a){
			if(x%f){
				flag=0;
			}
		}
		if(flag){
			cout<<f<<endl;
			return 0;;
		}
	}

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

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

	    long h=gl();
	    long w=gl();
	    
	    for (int i=0; i<h;i++) {
	    	String s=gs();
	    	System.out.println(s);
	    	System.out.println(s);
	    }

        //System.out.println(e);
//        if (xo>w || yo>h) {
//        	System.out.print(0);
//        }else {
//        	System.out.print((h-yo)*(w-xo));
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 37500