akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void solve(
    const vector<int>& x, const vector<int>& v,
    vector<vector<int> >& next, vector<int>& dp)
{
    int n = x.size();
    int m = v.size();

    next.assign(n+1, vector<int>(m, n));
    for(int i=0; i<m; ++i){
        int k = 0;
        for(int j=0; j<n; ++j){
            if(k < j)
                k = j;
            while(k + 1 < n && abs(x[k+1] - x[k]) <= v[i])
                ++ k;
            next[j][i] = k + 1;
        }
    }

    dp.assign(1<<m, 0);
    for(int i=0; i<(1<<m); ++i){
        bitset<32> bs(i);
        for(int j=0; j<m; ++j){
            if(bs[j])
                continue;
            bitset<32> bs2 = bs;
            bs2[j] = true;
            dp[bs2.to_ulong()] = max(dp[bs2.to_ulong()], next[dp[i]][j]);
        }
    }
}

int main()
{
    int n, v0;
    cin >> n >> v0;
    vector<int> x(n);
    for(int i=0; i<n; ++i)
        cin >> x[i];

    vector<int> v(1, v0);
    while(v.back() > 0)
        v.push_back(v.back() / 2);
    int m = v.size();

    vector<vector<int> > rightNext, leftNext;
    vector<int> rightDp, leftDp;
    solve(x, v, rightNext, rightDp);
    reverse(x.begin(), x.end());
    solve(x, v, leftNext, leftDp);

    vector<int> ans(n+1, 0);
    for(int i=0; i<(1<<m); ++i){
        if(i & 1)
            continue;

        int j = ((1<<m) - 1) ^ i ^ 1;
        if(rightNext[rightDp[i]][0] + leftDp[j] >= n){
            ++ ans[rightDp[i]];
            -- ans[rightNext[rightDp[i]][0]];
        }
    }
    for(int i=0; i<n; ++i)
        ans[i+1] += ans[i];

    for(int i=0; i<n; ++i){
        if(ans[i] > 0)
            cout << "Possible" << endl;
        else
            cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 54912
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        
        int S;
        S = ((a+b)*h)/2;
        System.out.println(S);
    }
}


Measured memory_bytes: 21844
import math
A, B, H, M = map(int, input().split())
Md = 2*math.pi * 1/60 * M
Hd = 2*math.pi * (1/12 * H + 1/(12*60)*M)

print( ( A**2 + B**2 - 2*A*B*math.cos(abs(Hd-Md)))**(1/2) )  

Measured memory_bytes: 62600
#define pb push_back
#define ff first
#define ss second
#define ll long long
#include <bits/stdc++.h>
using namespace std;

int n,k;
ll a[200005];

ll cal(ll b){
    ll sum = 0;
    for(int i=1;i<=n;i++){
        sum += abs(b+i-a[i]);
    }
    return sum;
}

int main(int argc, char const *argv[]) {
    cin>>n;
    k = 100;
    for(int i=1;i<=n;i++)cin>>a[i];
    ll l,r,tl,tr;
    r = 1e12;
    l = -1 * r;
    while(k--){
        //cout<<l<<" "<<r<<endl;
        tl= (l*2+r)/3;
        tr=(l+r*2)/3;
        if(cal(tr)>cal(tl))r = tr;
        else l = tl;
    }
    printf("%lld\n", cal(r-1));
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M; cin >> N >> M;
  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
}


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

void lcs(string X,string Y, int m, int n ) 
{ 
	int L[m+1][n+1]; 
	for (int i=0; i<=m; i++) 
	{ 
		for (int j=0; j<=n; j++) 
		{ 
			if (i == 0 || j == 0) 
				L[i][j] = 0; 
			else if (X[i-1] == Y[j-1]) 
				L[i][j] = L[i-1][j-1] + 1; 
			else
				L[i][j] = max(L[i-1][j], L[i][j-1]); 
		} 
	} 

	int index = L[m][n]; 
	char lcs[index+1]; 
	lcs[index] = '\0'; // Set the terminating character 

	int i = m, j = n;
	while (i > 0 && j > 0) {
		if (X[i-1] == Y[j-1]) { 
			lcs[index-1] = X[i-1]; // Put current character in result 
			i--; j--; index--;	 // reduce values of i, j and index 
		}	 
		else if (L[i-1][j] > L[i][j-1]) 
			i--; 
		else
			j--;
	}	 

	cout << lcs; 
} 
int main() 
{
	string X, Y;
	cin >> X >> Y;
	int m = (int) X.length();
	int n = (int) Y.length();
	lcs(X, Y, m, n); 
	return 0; 
} 


Measured memory_bytes: 35456
<?php
$numbers = fgets(STDIN);
$n = intval($numbers);
// print $n;

// $numbers1 = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
$numbers1 = explode(" ", rtrim(fgets(STDIN)));
// print_r($numbers);

$numbers2 = fgets(STDIN);
$n = intval($numbers);
// print $n;

$numbers2 = explode(" ", rtrim(fgets(STDIN)));
// print_r($numbers);
// print_r($numbers2);

$numbers_merge = array_diff($numbers1, $numbers2);
// sort($numbers_merge);

foreach ($numbers_merge as $nm){
    echo $nm;
    echo PHP_EOL;
}
// print_r($numbers_merge);


Measured memory_bytes: 101664
N, M= map(int, input().split())
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
A.sort()
ans = 0
for i in range(N):
  if A[i][1] < M:
    ans += A[i][0] * A[i][1]
    M -= A[i][1]
  else:
    ans += A[i][0] * M
    break
print(ans)

Measured memory_bytes: 90376
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> sa = suffix_array(s);
  vector<int> lcp = lcp_array(s,sa);
  ll ans = n-sa[0];
  for(int i = 1; i < n; ++i) ans += n-sa[i]-lcp[i-1];
  cout << ans;
  return 0;
}

Measured memory_bytes: 15616
Sp = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Hu = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Cr = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Dy = [1,2,3,4,5,6,7,8,9,10,11,12,13]

num = int(input())
i = 0

while i < num:
     suit, n = raw_input().split()
     n = int(n)
     if suit == "S":
        Sp[n-1] = 0
     elif suit == "H":
        Hu[n-1] = 0
     elif suit == "C":
        Cr[n-1] = 0
     else:
        Dy[n-1] = 0
     i += 1

for i in Sp:
    if i != 0:
        print "S", i

for i in Hu:
    if i != 0:
        print "H", i

for i in Cr:
    if i != 0:
        print "C", i

for i in Dy:
    if i != 0:
        print "D", i

Measured memory_bytes: 4284
#include<iostream>

using namespace std;

long long n, m, q;
long long seq[11];

bool next_a(){
    bool x = false;
    int keta = 0;
    do{
        if(keta == n) return false;
        seq[n-keta]++;
        if(seq[n-keta] > m){
            x = true;
            seq[n-keta] = 0;
            keta++;
        } else x = false;
    } while(x);
    for(long long i = 1; i < n; i++){
        if(seq[i+1] < 1) seq[i+1] = seq[i];
    }
    return true;
}

int main(){
    long long a[50], b[50], c[50], d[50];
    cin >> n >> m >> q;
    long long max_score = 0, pmax = 0;
    for(long long i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        pmax += d[i];
    }
    for(long long i = 1; i <= n; i++){
        seq[i] = 1;
    }

    do {
        long long score = 0;
        for(long long i = 0; i < q; i++){
            if(seq[b[i]] - seq[a[i]] == c[i]) score += d[i];
        }
        if(score > max_score) max_score = score;
        if(max_score == pmax) break;
    } while(next_a());

    cout << max_score << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>	
int main(void)
{
		int a,b,c,d,e,f;
		scanf("%d",&a);					
		scanf("%d",&b);
		if((a+b)%2>0) {
		f=(a+b)/2+1;
		}
		else {
		f=(a+b)/2;
		}
		printf("%d\n",f);
		return 0;
}			

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

A,B,C =map(int,input().split())
K = int(0)

while C>=7*A+B:
    C = C - (7*A+B)
    K += 1
#print(C)
if C>7*A:
    #print(A,C)
    C=7+7*K
elif C%A==0:
    #print(A,C)
    C=(C/A)+7*K
else:
    #print(A,C)
    C=(C/A)+1+7*K
    
print('%d'%C)


Measured memory_bytes: 5604
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cassert>
#include<cstdio>

#define MAX 12

using namespace std;
long double minimumLength;
long double boxLength;

long double CalculateRoleCakesLength(const vector<int> &r){
	long double ret;
	ret = r[0] + r[r.size() - 1];
	for(unsigned int i = 0; i < r.size() - 1; ++i){
		ret += 2 * sqrt((long double)(r[i]*r[i+1]));
	}
	return ret;
}
inline void InternalInsert(vector<int> &v, unsigned int a, unsigned int dest){
	if( a > dest ){
		v.insert( v.begin() + dest, v[a] );
		v.erase( v.begin() + a + 1);
	}else if( dest > a ){
		v.insert( v.begin() + dest, v[a] );
		v.erase( v.begin() + a);
	}
}
template <typename T>
void printVector( vector<T> &v ){
	for(unsigned int i = 0; i < v.size(); ++i) cout << v[i] << ' '; cout << endl;
}
bool OptimizeArrangeOfRoleCakes(long double *result, const long double target, vector<int> &vInBoxCakes){
	long double len;
	long double minlen;
	const long double nowlen = CalculateRoleCakesLength( vInBoxCakes );
	vector<pair<int,int> > vCands;

	minlen = target;
	for(unsigned int i = 0; i < vInBoxCakes.size(); ++i){
		for(unsigned int j = 0; j <= vInBoxCakes.size(); ++j){
			if( j >= i + 2 || j <= i - 1 ){
				InternalInsert( vInBoxCakes, i, j );
				len = CalculateRoleCakesLength( vInBoxCakes );
				if( len < minlen ){
					minlen = len;
					vCands.push_back( make_pair(i, j) );
				}
				if( i < j ) InternalInsert( vInBoxCakes, j - 1, i );
				else InternalInsert( vInBoxCakes, j, i + 1 );
			}
		}
	}
	if( vCands.size() > 0 ){
		long double retminlen = nowlen;
		int retminlenind = -1;

		for(unsigned int i = 0; i < vCands.size(); ++i){
			long double t;
			InternalInsert( vInBoxCakes, vCands[i].first, vCands[i].second );

			if( OptimizeArrangeOfRoleCakes(&t, minlen, vInBoxCakes ) ) return true;
			if( t < retminlen ){
				retminlen = t;
				minimumLength = min(minimumLength, retminlen);
				if( minimumLength <= boxLength ) return true;
				retminlenind = i;
			}
			
			if( vCands[i].first < vCands[i].second ){
				InternalInsert( vInBoxCakes, vCands[i].second - 1, vCands[i].first);
			}else{
				InternalInsert( vInBoxCakes, vCands[i].second, vCands[i].first + 1 );
			}
		}
		*result = retminlen;
		return false;
	}
	*result = nowlen;
	return false;
}
int main(void){
	while(true){

		long double length = 0;
		vector<int> vInBoxCakes;
		
		cin >> boxLength;
		if( cin.eof() ) break;
		while( true ){
			int tmp;

			if( '\n' == cin.get() ) break;
			cin >> tmp;
			vInBoxCakes.push_back(tmp);
		}

		minimumLength = CalculateRoleCakesLength( vInBoxCakes );
		OptimizeArrangeOfRoleCakes( &length, minimumLength, vInBoxCakes);

		//cout << "Minmum Length = " << minimumLength << endl;
		if( minimumLength <= boxLength ) cout << "OK\n";
		else cout << "NA\n";
	}
	return 0;
}

Measured memory_bytes: 956
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 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;}


void solve(){

  int n,m,a[50][50],b[50],c,ans=0;
  string str;

  cin >> n >> m >> c;
  FOR(i,m){
    cin >>b[i];
  }
  FOR(i,n){
    int temp=c;
    FOR(j,m){
      cin >> a[i][j];
      temp+=a[i][j]*b[j];
    }
    if(temp>0) ans ++;
  }
  
  cout << ans fin;

  

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = A[i] - i - 1
A = sorted(A)
medN = N//2

x = 0
for i in range(N):
    x = x + abs(A[i] - A[medN])
print(x)

Measured memory_bytes: 25200
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String r = "R";
    int count = s.indexOf(r);
    int lastcount = s.lastIndexOf(r);
    if(s.contentEquals("RRR")){
      System.out.println("3");
    }else if(s.contentEquals("SSR")){
      System.out.println("1");
    }else if(s.contentEquals("SRS")){
      System.out.println("1"); 
    }else if(s.contentEquals("RSS")){
      System.out.println("1");
    }else if(count == 0 && lastcount == 1 || count == 1 && lastcount == 2){
      System.out.println("2");
    }else if(count == 0 && lastcount == 2 || count == 2 && lastcount == -1|| count == 0 && lastcount == -1|| count == 1 && lastcount == -1 ){
      System.out.println("1");
    }else if(s.contentEquals("SSS")){
      System.out.println("0");

    }
  }
}



Measured memory_bytes: 35564
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 3e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  ll a, b, x;
  cin >> a >> b >> x;
  ll pref = x;
  for (int i = 0; i < 10; ++i) {
    cout << a * pref - b << '\n';
    pref = a * pref - b;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int A,B;
    cin >> A >> B;
    
    if(A%3==0 || B%3==0 || (A+B)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll m=1e9+7,n,h,w,k,a=1;
int main(void){
  cin>>h>>w>>k;
  n=h+w;
  if(k==1)cout<<2*n<<endl;
  else{
    a=(k+1)*(k-1)%m*k%m*333333336%m*h%m*w%m+(k)*(k+3)%m*n%m*(n-1)%m*500000004%m;
    a%=m;
  }
  for(ll i=n-2;i>=n-k+1;i--){
    a=a*i%m;
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

void addSelf(int& a,int b){
    a+=b;
    if(a>=mod){
        a-=mod;
    }
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int h,w;
    cin>>h>>w;
    char s[h][w];
    vector<vector<int>>dp(h,vector<int>(w));
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=i;k<=i+1;k++){
                int c2=j;
                if(k==i)
                    c2=j+1;
                if(k<h && c2<w && s[k][c2]=='.'){
                    addSelf(dp[k][c2],dp[i][j]);
                }
            }
        }
    }
    cout<<dp[h-1][w-1];
}

Measured memory_bytes: 5248
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int num_of_teams;
  int num_of_results;
  while(~scanf("%d %d",&num_of_teams,&num_of_results)){
    int depth[5002];
    vector<int> edges[5002];
    memset(depth,0,sizeof(depth));
    for(int i = 0; i < num_of_results; i++){
      int from,to;
      scanf("%d %d",&from,&to);
      edges[from].push_back(to);
      depth[to]++;
    }

    queue<int> que;
    for(int team = 1; team <= num_of_teams; team++){
      if(depth[team] == 0){
        que.push(team);
      }
    }
    
    bool has_many = false;
    while(!que.empty()){
      if(que.size() >= 2){
        has_many = true;
      }
      int team = que.front();
      que.pop();
      printf("%d\n",team);
      for(int i = 0; i < edges[team].size(); i++){
        int next = edges[team][i];
        depth[next]--;
        if(depth[next] == 0){
          que.push(next);
        }
      }
    }

    printf("%d\n",has_many ? 1 : 0);
  }
}

Measured memory_bytes: 1892
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    ll n,a,b;scanf("%lld %lld %lld",&n,&a,&b);

    if((b-a)%2==0){
        printf("%lld\n", (b-a)/2);
    }else{
        ll a1 = (a-1) + (b-a-1)/2 + 1;
        ll a2 = (n-b) + (b-a-1)/2 + 1;
        printf("%lld\n", min(a1,a2));
    }
}


Measured memory_bytes: 256
import math 
def isPrime(n):
    if n == 1:
        return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
def nextPrime(N):
    if N <= 1:
        return 2
    prime = N
    found = False
    while(not found): 
        prime = prime + 1
        if(isPrime(prime) == True): 
            found = True
    return prime 
A = int(input())
N = A-1
print(nextPrime(N)) 

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

void insert_sort(int a[], int n){
    REP(i,1,n){
        int v = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] >= v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;

        rep(j,n){
            printf("%d", a[j]);
            if(j < n-1)printf(" ");
            else printf("\n");
        }
    }
}

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    rep(j,n){
        printf("%d", a[j]);
        if(j < n-1)printf(" ");
        else printf("\n");
    }
    
    insert_sort(a, n);

    return 0;
}


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

typedef long long ll;

int main() {
    ll N;
    vector<ll> H;
    cin >> N;
    H.resize(N);
    for (ll i=0;i<N;i++) cin >> H[i];
    ll x = 0;
    ll M = 0;
    for (ll i=0;i<N-1;i++){
        if (H[i] >= H[i+1]) x++;
        else {
            if (M < x) M = x;
            x = 0;
        }
        if (i==N-2){
            if (M < x) M = x;
        }
    }
    cout << M << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const ll MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  int n;
  cin >> n;
  unordered_map<string,int>mp;
  vector<string>l(4);
  l={"AC","WA","TLE","RE"};

  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    mp[s]++;
  }
  for(auto v:l){
    cout<< v << " x " <<mp[v]<<endl;
  }
}


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

using namespace std;

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

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define G0 get< 0 >
#define G1 get< 1 >
#define G2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

ll c;

void calc(string s) {
  if (s.size() == 1) {
    c += atoi(s.c_str());
    return;
  }

  if (s.find('+') == string::npos) {
    c += atoll(s.c_str());
    return;
  }

  int l = 0;
  s = s + "+";
  for (int r = 1; r < s.size(); r++) {
    if (s[r] == '+') {
      // cout << s.substr(l, r - l) << endl;
      c += atoll(s.substr(l, r - l).c_str());
      l = r + 1;
    }
  }
}

void dfs(string s, int size, int i) {
  if (size < i + 1) {
    // cout << i << ": " << s << endl;

    calc(s);
    return;
  }

  string in = s;
  // in
  in.insert(i, "+");
  dfs(in, size + 1, i + 2);

  // not in
  dfs(s, size, i + 1);
}

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

  string s;
  cin >> s;

  dfs(s, s.size(), 1);

  cout << c << endl;

  return 0;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

int main ()
{
    string S;
    int res,cnt;

    cin >> S;
    
    cnt = 0;
    res = 0;
    REPI (S.size ())
    {
        if (S[i]=='A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C')
            cnt++;
        else{
            if (cnt > res)
                res = cnt;
            cnt = 0;
        }
    }
    
    if (cnt > res)
        res = cnt;
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
MOD = 10 ** 9 + 7
n_all = (10 ** n) % MOD
zero_or_nine_all = (9 ** n) % MOD
not_zero_and_nine_all = (8 ** n) % MOD

t = (zero_or_nine_all - not_zero_and_nine_all) % MOD

ans = (n_all - zero_or_nine_all -t) % MOD

print(ans)


Measured memory_bytes: 10644
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	b+=a;
	string s;
	cin>>s;
	for(int i=0;i<=b;i++)
	{
		if((s[i]<'0'||s[i]>'9')&&i!=a)
			return!(cout<<"No\n");
		if(i==a&&s[i]!='-')
			return!(cout<<"No\n");
	}
	return!(cout<<"Yes\n");
}

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

#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}



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

int main(){
  int n,x,t;
  cin >> n >> x >> t;
  int count = 0;
  
  while(n > 0){
    if(n < x){
      n = 0;
      count += t;
    }
    else {
      n -= x;
      count += t;
    }
  }
  
  cout << count << endl;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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 modPow(long long a, long long n, long long p) {
    if (n == 0) return 1; // 0乗にも対応する場合
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}
int modDev(lol a, lol b, lol c)
{
    if(a < b || a < 0) return 1;
    return (a*(modPow(b, c-2, c)))%MOD;
}
int finds(lol a[], lol b, lol c)
{
    REP(i, c)
    {
        if(a[i] == b) return i;
    }
    return -1;
}

int main()
{
    lol result{0};
    lol a[100005] = {}, count = 0;
    lol n, x, m; cin >> n >> x >> m;
    lol prex = x;
    lol save2 = 0, save3 = 0;
    //bool TF = false;
    a[0] = x;
    FOR(i, 2, n)
    {
        lol save = (prex*prex)%m;
        if(finds(a, save, count) != -1)
        {
            save2 = finds(a, save, count);
            break;
        }
        else
        {
            count++;
            a[count] = save;
            prex = save;
        }
        
    }
    FOR(i, save2, count)
    {
        save3 += a[i];
    }
    lol nm = count - save2 + 1;
    REP(i, save2) result += a[i];
    lol nm2 = (n-save2)/nm;
    lol nmr = (n-save2)%nm;
    result += save3*nm2;
    REP(i, nmr)
    {
        result += a[save2+i];
    }
    

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

Measured memory_bytes: 4424
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,t,temp,x,y;
string str;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	cin>>a>>b;
	cin>>str;
	if(str==s)
	a--;
	else
	b--;
	cout<<a<<' '<<b;
	
	
	
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int a[N],b[N];
struct edge{
	int x,y;
}e[N];
bool cmp(edge a,edge b){
	if(a.x!=b.x)return a.x<b.x;
	return a.y<b.y;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(x>y)swap(x,y);
		e[i].x=x;e[i].y=y;
	}
	
	if(a[e[0].x]<a[e[0].y])b[e[0].x]=true;
	else if(a[e[0].x]>a[e[0].y])b[e[0].y]=true;
	else {
		b[e[0].x]=true;b[e[0].y]=true;
	}
	for(int i=1;i<m;i++){
		if(e[i].x==e[i-1].x && e[i].y==e[i-1].y){
			b[e[i].x]=true;b[e[i].y]=true;
		}
		else {
			if(a[e[i].x]<a[e[i].y])b[e[i].x]=true;
			else if(a[e[i].x]>a[e[i].y])b[e[i].y]=true;
			else {
				b[e[i].x]=true;b[e[i].y]=true;
			}
		}
	}
	
	int ans=0;
	for(int i=1;i<=n;i++){
		if(b[i]==false)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

int n,q;
vector<int> tree[200010];
int cost[200010];
int done[200010];

void dfs(int s,ll sum) {
    if (done[s]==1) return;
    done[s]=1;
    int c=cost[s];
    cost[s]+=sum;
    if (tree[s].size()==0) return;
    for (int i=0;i<tree[s].size();i++) {
        dfs(tree[s][i],sum+(ll)c);
    }
}



int main () {
    
    cin>>n>>q;
    rep(i,n-1) {
        int a,b;cin>>a>>b;
        a--;b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    rep(i,n) {
        cost[i]=0;
    }
    rep(i,q) {
        int p,x;cin>>p>>x;
        p--;
        cost[p]+=x;
    }
    rep(i,n) {
        done[i]=0;
    }

    dfs(0,0);

    rep(i,n) {
        cout<<cost[i]<<endl;
    }

}

Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n;
	cin>>n;//10^5
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	ll color=0,total=0;
	rep(i,n){
		if(2*total>=a[i]){
			color++;
		}else{
			color=0;
			color++;
		}
		total+=a[i];
	}
	cout<<color<<endl;


    return 0;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d %d", $posa, $speeda);
fscanf(STDIN, "%d %d", $posb, $speedb);
fscanf(STDIN, "%d", $timelimit);

if($posa === $posb) {
    echo "YES";
    exit(0);
}
if($speeda <= $speedb) {
    echo "NO";
} else {
    $distance = abs($posa - $posb);
    $speed = abs($speeda - $speedb);
    $time = $distance / $speed;
    if($time <= $timelimit) {
        echo "YES";
    } else {
        echo "NO";
    }
}


Measured memory_bytes: 16232
#include <algorithm>
#include <iostream>
#include <string>

#include <vector>
#include <cmath>
#include <limits>
#include <functional>
using namespace std;

int main()
{
    int N, L;
    cin >> N >> L;
   
    string ans = "";

    vector<string> vec(N);
    for (int i = 0; i < N; i++)
        cin >> vec[i];
    sort(vec.begin(), vec.end()); 

    for (int i = 0; i < N;i++){
        ans += vec[i];
    }

        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int dp[3005][3005];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin>>s>>t;
    int n,m;
    n=s.size();
    m=t.size();
    dp[0][0]=0;
    if(s[0]==t[0])
    {
        dp[1][1]=1;
    }
    else
    {
        dp[1][1]=0;
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string res="";
    int i=n,j=m;
    int x=dp[n][m];
    while(i>=1 || j>=1)
    {
        if(i>0 &&dp[i-1][j]==x)
        {
            i--;
        }
        else if(j>0 && dp[i][j-1]==x)
        {
            j--;
        }
        else if(i>0 && j>0 &&dp[i-1][j-1]==x-1)
        {
            x--;
            j--;
            i--;
            res+=s[i];

        }
        else{
            break;
        }
    }
    reverse(res.begin(),res.end());
    for(int i=0; i<res.size(); i++)
    {
        cout<<res[i];
    }
    return 0;
}



Measured memory_bytes: 70784
// 2011/01/14 Tazoe

#include <iostream>
using namespace std;

void ABC_sort(int& A, int& B, int& C)
{
	int tmp[3] = {A, B, C};

	for(int i=0; i<2; i++)
		for(int j=i+1; j<3; j++)
			if(tmp[i]>tmp[j]){
				int swp = tmp[i];
				tmp[i] = tmp[j];
				tmp[j] = swp;
			}

	A = tmp[0];
	B = tmp[1];
	C = tmp[2];
}

int main()
{
	while(true){
		int A, B, C;
		cin >> A >> B >> C;
		if(A==0&&B==0&&C==0)
			break;

		ABC_sort(A, B, C);
		int D = A*A+B*B;

		int n;
		cin >> n;

		for(int i=0; i<n; i++){
			int R;
			cin >> R;
			if(D<4*R*R)
				cout << "OK" << endl;
			else
				cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long
int n;
ll t[1111];

ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int main(){	
	cin>>n;
	rep(i,n)cin>>t[i];
	ll g=t[0],m=t[0];

	for(int i=1;i<n;i++){
		g=gcd(m,t[i]);
		m=m/g*t[i];
	}
	cout<<m<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define w while
#define loop(i,l,r) for(int i=l;i<r;i++)
#define ci cin>>
#define co cout<<
#define ll long long
using namespace std;
int main()
{  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int n;
       cin>>n;
       int a[n][3];
       loop(i,0,n){
         loop(j,0,3){
           ci a[i][j];
         }
       }
       vector<int>dp(3,0);
       loop(i,0,n){
         vector<int>up(3,0);
         loop(j,0,3){
           loop(k,0,3){
             if(j!=k){
               up[j]=max(up[j],dp[k]+a[i][j]);
             }
           }
         }
         dp=up;
       }
       cout<<max(dp[0],max(dp[1],dp[2]));
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007

typedef pair<int, int> pii;
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, x, y; cin>>n>>x>>y;
	int dist[n+1] = {};
	vector<int> tmp(n+1);
	for(int i = 1; i <= n; i++){
		for(int u = 1; u <= n; u++) tmp[u] = 1e9;
		tmp[i] = 0;
		queue<int> q;
		q.push(i);
		while(!q.empty()){
			int cur = q.front();
			q.pop();
			if(cur-1 && tmp[cur-1] > tmp[cur]+1){
				q.push(cur-1);
				tmp[cur-1] = tmp[cur]+1;
			}
			if(cur+1 <= n && tmp[cur+1] > tmp[cur]+1){
				q.push(cur+1);
				tmp[cur+1] = tmp[cur]+1;
			}
			if(cur==x && tmp[y] > tmp[x]+1){
				q.push(y);
				tmp[y] = tmp[x]+1;
			}
			if(cur==y && tmp[x] > tmp[y]+1){
				q.push(x);
				tmp[x] = tmp[y]+1;
			}
		}
		for(int u = 1; u <= n; u++){
			dist[tmp[u]]++;
		}
		//for(int u = 1; u <= n; u++) cout<<dist[u]<<" ";
		//cout<<endl;
	}
	for(int i = 1; i <= n-1; i++) cout<<dist[i]/2<<"\n";
}

Measured memory_bytes: 256
using System;
namespace MSOLUTIONS.Problems
{
    class A
    {
        static void Main()
        {
            int x = int.Parse(Console.ReadLine());
            int rating = 0;
            if (x >= 400 && x < 600)
            {
                rating = 8;
            }
            else if (x >= 600 && x < 800)
            {
                rating = 7;
            }
            else if (x >= 800 && x < 1000)
            {
                rating = 6;
            }
            else if (x >= 800 && x < 1000)
            {
                rating = 6;
            }
            else if (x >= 1000 && x < 1200)
            {
                rating = 5;
            }
            else if (x >= 1200 && x < 1400)
            {
                rating = 4;
            }
            else if (x >= 1400 && x < 1600)
            {
                rating = 3;
            }
            else if (x >= 1600 && x < 1800)
            {
                rating = 2;
            }
            else if (x >= 1800 && x < 2000)
            {
                rating = 1;
            }
            else
            {
                // Nothing
                ;
            }
            Console.WriteLine(rating);
        }
    }
}


Measured memory_bytes: 27512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define find(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

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

const ll MOD = 1000000007; // 10^9 + 7

int cntDivisors(int n) {
  int ret = 0;
  int lim = int(sqrt(n));
  for (int i = 1; i <= lim; i++) {
    if (n % i > 0) continue;
    ret += 2;
    if (i == n / i) ret--;
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));

  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    if (cntDivisors(i) == 8) ans++;
  }
  outl(ans)
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int a,b,c,d;

int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d) {
        cout << "Yes" << endl;
    } else {
        if ( abs(a-b) <= d && abs(b-c) <= d) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll C[106];

int main(){
  ll X,N,ma=INF,key=0;
  cin >>X >> N;
  rep(i,N){
    ll D;
    cin >> D;
    C[D]=1;
  }

  Rep(i,-2,104){
if(C[i]==0){
  if(abs(X-i)<ma){
    key=i;
    ma=abs(X-i);
  }
}
  }
  cout << key << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

int numY[200000];
int numX[200000];
std::pair<int,int> pos[200000];

template<class T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<class ARR, size_t N, class T>
void fill_all(ARR(& arr)[N], const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}


int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> pos[i].first; --pos[i].first;
		cin >> pos[i].second; --pos[i].second;
	}
	fill_all(numX, -1);
	fill_all(numY, -1);

	int grid = 0;
	for (int i = 0; i < N; ++i) {
		if (pos[i].first == pos[i].second) {
			++grid;
		}
		if (numX[pos[i].first] == -1 && numY[pos[i].second] == -1) {
			numX[pos[i].first] = i;
			numY[pos[i].second] = i;
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}

	int count = 0;
	for (int i = 0; i < N; ++i) {
		if (pos[i].first != pos[i].second) {
			++count;
			auto target = numX[pos[i].second];
			std::swap(pos[target].first, pos[i].first);
			numX[pos[i].first] = i;
			numX[pos[target].first] = target;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 5460
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int count = 0;

    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '+') {
        count++;
      } else if (s.charAt(i) == '-') {
        count--;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

li gcd(int a,int b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  if(df) printf("*debug mode*\n");
  int a,b; cin >>a >>b;
  printf("%ld",(li)a/gcd(a,b)*b);
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include<iostream>
    #include<string>
    #include<algorithm>
    #include<map>
    #include<vector>
    using namespace std;
    int main()
    {
        int n,x,y,cnt=0;
        cin>>n;
        for(x=0;x<26;x++){
            for(y=0;y<15;y++){
                if(4*x+7*y==n){
                    cnt++;
                }
            }
        }
        if(n%4==0)
        cnt++;
        if(n%7==0)
        cnt++;
        if(cnt>0)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
        return 0;
    }

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  string T = "RGBRG";
  long ans = 0;
  for (int i = 0; i < N; i++) {
    int t = T.find(S.at(i));
    char a = T.at(t + 1);
    char b = T.at(t + 2);
    string s1 = S.substr(0, i);
    string s2 = S.substr(i + 1);
    int a1 = count(s1.begin(), s1.end(), a);
    int a2 = count(s2.begin(), s2.end(), a);
    int b1 = count(s1.begin(), s1.end(), b);
    int b2 = count(s2.begin(), s2.end(), b);
    reverse(s1.begin(), s1.end());
    int mi = min(s1.size(), s2.size());
    int ng = 0;
    for (int j = 0; j < mi; j++) {
      if ((s1.at(j) == a && s2.at(j) == b) || (s1.at(j) == b && s2.at(j) == a)) ng++;
    }
    ans += a1 * b2 + a2 * b1 - ng;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3616
import math
n=int(input())
p=[]
for x in range(2,5555):
    t=True
    for y in range(2,math.ceil(math.sqrt(x))+1):
        if x%y==0:t=False
    if t:p.append(x)
c=0
ans=[]
for i in range(len(p)):
    if p[i]%5==1:
        ans.append(p[i])
        c+=1
    if c==n:break
s=''
for x in ans:
    s+=str(x)+' '
print(s)

Measured memory_bytes: 9196
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private static Scanner sc;

  private void run() {
    sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());

    if (A < 10 && B < 10) {
      System.out.println(A * B);
    } else {
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 27016
// Mo's algorithm
// 例題：数列の区間内の要素の種類数を求める  ABC174 F
 
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
 
struct Mo {
    vector<int> left, right, index; // offline query
    int window; // bucket width
    int nl, nr, ptr; // [nl,nr)
    vector<int> a; // input
    // add,delで書き換えていく
    vector<int> count;
    int sum;
    
    Mo(int n, vector<int> aa) : window((int)sqrt(n)), nl(0), nr(0), ptr(0), count(n+1,0), sum(0) { a = aa; }
    
    /* query [l,r) 0-indexed */
    void push(int l, int r) { left.push_back(l), right.push_back(r); }
    
    /* query sort */
    void build() {
        index.resize(left.size());
        iota(index.begin(), index.end(), 0);
        sort(index.begin(), index.end(), [&](int a, int b){
            if (left[a] / window != left[b] / window) return left[a] < left[b];
            if((left[a] / window) % 2) return right[a] > right[b];
            return right[a] < right[b];
        });
    }
 
    /* 問題ごとに書き換える */
    void add(int id){ if(count[a[id]]++ == 0) sum++; return; };
    void del(int id){ if(--count[a[id]] == 0) sum--; return; }
    
    /* 区間を次のquery用に伸縮させる */
    pair<int,int> next() {
        const auto i = index[ptr++];
        while (left[i] < nl ) add(--nl);
        while (nr < right[i]) add(nr++);
        while (nl < left[i] ) del(nl++);
        while (right[i] < nr) del(--nr);
        return make_pair(i,sum);
    } // 返り値はquery-index
};
 
int n, q, l, r;
 
int main() {
    scanf("%d %d", &n, &q); 
    vector<int> a(n);
    rep(i,n) scanf("%d", &a[i]);
    Mo mo(n,a);
    rep(i,q){ cin >> l >> r; mo.push(--l, r); }
 
    mo.build();
    vector<int> res(q);
    rep(i,q) { auto p = mo.next(); res[p.first] = p.second; }
    rep(i,q) printf("%d\n", res[i]);
    return 0;
}

Measured memory_bytes: 18492
#include <stdio.h>

int main(){
  int i,j,a,b[3][3],c[3]={0,0,0},n,f[3]={7,7,7},g=0;
  for(i=0;i<9;i++){
  	scanf("%d",&b[i/3][i%3]);
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
  	scanf("%d",&a);
    for(j=0;j<9;j++){
      if(b[j/3][j%3]==a){
        c[j/3]|=1<<(j%3);
        break;
      }
    }
  }
  for(i=0;i<3;i++){
    if(c[i]==7){
      g=1;
      break;
    }
    f[0]&=c[i];
    f[1]&=(c[i]<<i)&4;
    f[2]&=(c[i]<<(2-i))&4;
  }
  for(i=0;i<3;i++){
    if(f[i]!=0){
      g=1;
      break;
    }
  }
  if(g){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}


Measured memory_bytes: 128