akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

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

    ll x=__gcd(1LL<<30,ll(a[0]));
    for(int i=0;i<n;i++){
        if(x!=__gcd(1LL<<30,ll(a[i]))){
            cout<<0<<endl;
            return 0;
        }
    }
    if(x==0){
        cout<<0<<endl;
        return 0;
    }
    ll piyo=1LL<<30;
    
    ll v=1;
    for(int i=0;i<n;i++){
        v=v/__gcd(ll(a[i]/2),v)*(a[i]/2);
        if(v>m){
            cout<<0<<endl;
            return 0;
        }
    }
    
    int lb=0;
    int ub=m/v;

    ub++;
    ub/=2;
    
    cout<<ub-lb<<endl;

    
    
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
const std::string YESNO[2] = {"NO", "YES"};

const std::string TERMS[4] = {"dreamer", "dream", "eraser", "erase"};
std::string S;
int L;


bool rec(int idx){
    if(idx == L){return true;}

    for(int i=0;i<4;++i){
        if(idx + TERMS[i].size() > L){
            continue;
        }

        int j = 0;
        for(;j<TERMS[i].size();++j){
            if(S[idx+j] != TERMS[i][j]){
                break;
            }
        }

        if(j == TERMS[i].size() &&
           rec(idx + j)){
            return true;
        }
    }
    
    return false;
}

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

    std::cin >> S;
    L = S.size();
    
    std::cout << YESNO[rec(0)] << std::endl;
}


Measured memory_bytes: 1616
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define ff(i,s,n) for(int i=s;i<n;i++)
#define fr(i,s,n) for(int i=n-1;i>=s;i--)
#define llu long long int

bool isDivBy9(int n) 
{ 
    // Base cases 
    if (n == 0 || n == 9) 
        return true; 
    if (n < 9) 
        return false; 
  
    // If n is greater than 9, then recur for [floor(n/9) - n%8] 
    return isDivBy9((int)(n >> 3) - (int)(n & 7)); 
} 

int main() {
	string s;
	cin>>s;
	llu tot=0;
	for(int i=0;i<s.length();i++){
		int p=s[i]-'0' ;
		tot+=p;
	}
	
	if (isDivBy9(tot)) 
        cout<<"Yes";
	else
		cout<<"No";
}

//1
//7 2
//3 5 4 5 1 1 1


Measured memory_bytes: 3456
import java.io.IOException;
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args) throws IOException {
		String a=scan.next();
		char ch1=a.charAt(0);
		char ch2=a.charAt(1);
		char ch3=a.charAt(2);
		char ch4=a.charAt(3);
		if(ch1==ch2||ch2==ch3||ch3==ch4) {
			System.out.println("Bad");
		}
		else {
			System.out.println("Good");
		}
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    // スライムの数
    int slimesCnt = scanner.nextInt();
    // スライムの並び
    String slimes = scanner.next();
    // 出力用
    String output = String.valueOf(slimes.charAt(0));
    
    for (int i = 0; i < slimesCnt - 1; i++){
      if (output.charAt(output.length() - 1) != (slimes.charAt(i + 1))){
        output = output.concat(String.valueOf(slimes.charAt(i + 1)));
      }
    }
    
    System.out.println(output.length());
  }

}


Measured memory_bytes: 346280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X[]={300000, 200000, 100000};
  int Y[]={300000, 200000, 100000};
  int x,y,z;
  cin >> x >> y;
  z  = x<=3 ? X[x-1] : 0;
  z += y<=3 ? Y[y-1] : 0;
  z += (x==1 && y == 1) ? 400000 : 0;
  cout << z << endl;
  return 0;
}


Measured memory_bytes: 256
local t={}
for i=2,10^5 do
    t[i]=1
end

local p={}
for i=2,10^5 do
    if t[i]>0 then
        p[i]=1
        for j=2,10^5//i do
            t[i*j]=0
        end
    end
end

local s={}
s[0],s[1]=0,0
for i=2,10^5 do
    if p[i] and p[(i+1)//2] then
        s[i]=s[i-1]+1
    else
        s[i]=s[i-1]
    end
end

local q=io.read("n")
for i=1,q do
    local l,r=io.read("n","n")
    print(s[r]-s[l-1])
end

Measured memory_bytes: 7148
#include <bits/stdc++.h>
using namespace std;
#define A<B<C<D<E<F

int main() {
  string a,b; cin >> a >> b;
  if(a>b) cout << ">" << endl;
  else if(a<b) cout << "<" << endl;
  else cout << "=" << endl;
  return 0;
}

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

using namespace std;


long long extgcd(long long a)
{
	long long b = MOD;
	long long u = 1, v = 0, q; 
	while ( b > 0 ) {
		q = a / b; 
		a -= q * b; swap(a,b);
		u -= q * v; swap(u,v);
	}
	u %= MOD;
	while (u<0)
		u+=MOD;
	return u;
}
long long comb(long long n,long long k)
{
	long long t = 1;
	long long j = k;
	for(long long i = n; i  >= n-k+1; i--) {
		t *= i;
		t %= MOD;
		t *= extgcd(j);
		t %= MOD;
		j--;
	}  
  	while (t<0)
		t += MOD;
	return t;
}

int main(){
	int n,m,t=0;
	cin >>n >> m;
	vector<long> x(m);
	rep(i, m){
		cin >> x[i];
      	t += x[i];
	}
	cout << (n-t<0 ? -1 : n-t) << endl;
	
}


Measured memory_bytes: 3632
n,a,b=map(int,input().split())
s=input()
all=a+b
inter=b
for i in range(n):
  if all==0:
    print('No')
  elif s[i]=='a':
    print('Yes')
    all-=1
  elif s[i]=='b' and inter>0:
    print('Yes')
    all-=1
    inter-=1
  else:
    print('No')

Measured memory_bytes: 4016
from bisect import bisect

from string import ascii_lowercase

s = input()
t = input()

dp = {c: [] for c in ascii_lowercase}
for i, c in enumerate(s):
    dp[c].append(i)

N = len(s)
ans = 0
prev = -1
# print(dp)
for c in t:
    if not dp[c]:
        ans = -1
        break
    i = bisect(dp[c], prev)
    if i == len(dp[c]):
        i = 0
    k = dp[c][i]
    # print(k)
    if k > prev:
        d = k - prev
    elif k == prev:
        d = N
    else:
        d = N + k - prev
    # print('d:', d)
    ans += d
    prev = dp[c][i]
print(ans)


Measured memory_bytes: 46064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define N 1002
#define INF 1e9+1

int Levenshtein(string s1,string s2){
	vector<vector<int> > dp;
	int ss1=s1.size(),ss2=s2.size();
	int n=max(ss1,ss2)+1;
	dp.resize(n);for(int i=0;i<n;i++)dp[i].resize(n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			dp[i][j]=-1;
	for(int i=0;i<ss1+1;i++)dp[i][0]=i;
	for(int i=0;i<ss2+1;i++)dp[0][i]=i;
	for(int i=1;i<ss1+1;i++){
		for(int j=1;j<ss2+1;j++){
			int a,b=1;
			if(s1[i-1]==s2[j-1])b=0;
			a=min(dp[i-1][j]+1,dp[i][j-1]+1);
			a=min(a,dp[i-1][j-1]+b);
			dp[i][j]=a;
		}
	}
	return dp[s1.size()][s2.size()];
}

string s1,s2;
int main(){
	cin>>s1>>s2;
	cout<<Levenshtein(s1,s2)<<endl;
	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        char s = sc.NextString()[0];
        
        Console.WriteLine(s == 'A' ? 'T' : s == 'T' ? 'A' : s == 'G' ? 'C' : 'G');
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

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

int main(void)
{
    string SA, SB, SC;
    cin >> SA >> SB >> SC;
    int ia{0}, ib{0}, ic{0};
    char player = 'a';

    while(true){
        if(player == 'a'){
            if(ia<SA.size()){
                player = SA[ia];
                ++ia;
            }
            else{
                cout << "A" << endl;
                return(0);
            }
        }
        else if(player == 'b'){
            if(ib<SB.size()){
                player = SB[ib];
                ++ib;
            }
            else{
                cout << "B" << endl;
                return(0);
            }
        }
        else if(player == 'c'){
            if(ic<SC.size()){
                player = SC[ic];
                ++ic;
            }
            else{
                cout << "C" << endl;
                return(0);
            }
        }
    }
}


Measured memory_bytes: 256
#coding: utf-8
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
A = np.array([list(map(int, input().split())) for _ in range(N)])
sum_ = np.array([np.sum(A[i] * B) + C for i in range(N)])
print(np.sum(sum_ > 0))

Measured memory_bytes: 21656
//By Krishna Yadav
#pragma GCC optimize("-O2")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forstl(i, v) for (auto &i : v)
#define forn(i, e) for (int i = 0; i < e; i++)
#define ln "\n"

#define dbg(x) cout << #x << " = " << x << ln
#define dbg2(x, y) cout << #x << " = " << x << " & " << #y << " = " << y << ln
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef map<int, int> m32;
const int LIM = 2e5 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y;

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


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(b - a == c - b){
      System.out.println("YES");
    }
    else
      System.out.println("NO");
  }
}


Measured memory_bytes: 22100
#include <stdio.h>

int main(void)
{
	int d, s;
	int i;
	
	while (scanf("%d", &d) != EOF){
		s = 0;
		for (i = 0; i < 600; i += d){
			s += (i * i * d);
		}
		printf("%d\n", s);
	}
	
	return (0);
}

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




int main(){
    double xa, ya, ra, xb, yb, rb;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
	cin >> xa >> ya >> ra >> xb >> yb >> rb;
	double distance = sqrt(pow(xa - xb, 2) + pow(ya - yb, 2));
	if (distance > ra + rb) cout << 0;
	else if (distance < ra - rb) cout << 2;
	else if (distance < rb - ra) cout << -2;
	else cout << 1;
	cout << endl;
    }
}

Measured memory_bytes: 0
/**
*Keep
**Moving
***Forward
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define f( i , x , n ) for(int i = x; i < (int)(n); ++i)
#define pb push_back
#define all(c) (c).begin(),(c).end()

int a[100005];

int main(){
    int n;
    cin >> n;
    int mx = 0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    int c = 0;
    for(int i=1;i<=n;i++){
        if(a[i]==i){
                c++;
                int x = a[i];
                a[i] = a[i+1];
                a[i+1] = x;
        }
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

vector<pii> v;
int N;
int main(){

  cin>>N;
  for(int i=0;i<N;i++){
    int x,y;
    cin>>x>>y;
    v.push_back(pii(x,y));
  }
  sort(v.begin(),v.end());
  int dist=1<<30;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int d=0;
      d+=(v[i].first-v[j].first)*(v[i].first-v[j].first);
      if(d>=dist)break;
      d+=(v[i].second-v[j].second)*(v[i].second-v[j].second);
      dist=min(dist,d);
    }
  }
  cout<<dist<<endl;
  
  
  return 0;
}

Measured memory_bytes: 6444
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int A, B, C;

signed main(){
    cin >> A >> B >> C;
    swap(A, B);
    swap(A, C);
    cout << A << " " << B << " " << C << endl;
}

Measured memory_bytes: 256
n = int(input());
p = input().split(' ');

for i in range(n) :
	p[i] = int(p[i]);

dp = [0]*n;
flg = [1]*n;
comp = n+1;

for i in range(1,n) :
	if p[i-1] < p[i] and p[i-1] < comp :
		comp = p[i-1];
	if p[i] > comp :
		flg[i] = 0;


print(sum(flg));

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

int main(){
	string L[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"}; 
  
	string s;
	cin >> s;
  	
	for (int i = 0; i < 7; i++){
      	if (s == L[i]){
    	cout << (7-i) << endl;
        }
    }
	return 0;	
}


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

#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    string s;
    cin>>s;
    int east=0,west=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='E') east++;
        else west++;
    }
    int temp_east=0,temp_west=0;
    int minm=INT32_MAX;
    for(int i=0;i<s.length();i++){
        if(s[i]=='E'){
            temp_east++;
            minm=min(minm,temp_west+east-temp_east);
        } else if(s[i]=='W'){
            temp_west++;
            minm=min(minm,temp_west+east-temp_east-1);
        }
    }
    cout<<minm<<"\n";
    return 0;
}

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

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

int n,k;
cin>>n;
string s;
cin>>s>>k;
for(int i=0;i<s.length();i++){
if(s[i]!=s[k-1]){
s[i]='*';}}
cout<<s;
return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

//0:red,1:blue
map<string,map<string,int> > mp[2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n *= 2;
    string s;
    cin >> s;
    rep(i,(1 << (n-n/2))){
        string red,blue;
        rep(j,n-n/2){
            if((i >> j) & 1){
                red.pb(s[j+n/2]);
            }else{
                blue.pb(s[j+n/2]);
            }
        }
        reverse(all(blue));
        if(len(red) <= len(blue)){
            mp[0][blue][red]++;
        }else{
            mp[1][red][blue]++;
        }
    }
    ll ans = 0;
    rep(i,(1 << n/2)){
        string red, blue;
        rep(j,n/2){
            if((i >> j) & 1){
                red.pb(s[j]);
            }else{
                blue.pb(s[j]);
            }
        }
        reverse(all(blue));
        if(len(red) >= len(blue)){
            ans += mp[0][red][blue];
        }else{
            ans += mp[1][blue][red];
        }
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

uint64_t top_digit(uint64_t x)
{
  stringstream ss;
  ss << x;
  string s = ss.str();
  return s[0] - '0';
}

int main()
{
  uint64_t N;
  cin >> N;
  
  array<array<uint64_t, 10>,10> c;
  N_TIMES(i, 10) {
    N_TIMES(j, 10) {
      c[i][j] = 0;
    }
  }
  
  N_TIMES(n, N) {
    uint64_t j = (n + 1) % 10;
    uint64_t i = top_digit(n + 1);
    ++c[i][j];
  }
  
  uint64_t S = 0;
  N_TIMES(i, 10) {
    N_TIMES(j, 10) {
      S += c[i][j] * c[j][i];
    }
  }
  cout << S <<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a,b;
  cin>>a>>b;
  int n=b.length();
  int m=a.length();
  int dp[n+1][m+1];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      if(a[j-1]==b[i-1])
      {
        dp[i][j]=1+dp[i-1][j-1];
      }
      else
      {
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }
 // cout<<dp[n][m]<<endl;
  string ans="";
  int i=n;
  int j=m;
  while(i>0 && j>0)
  {
    if(a[j-1]==b[i-1])
    {
      ans=a[j-1]+ans;
      j--;
      i--;
    }
    else
    {
      if(dp[i-1][j]>dp[i][j-1])
      {
        i--;
      }
      else
      {
        j--;
      }
    }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 38856
#include <bits/stdc++.h>
using namespace std;
#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++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


/* ACL */

//using namespace atcoder;



int main(){
    ll N;
    cin >> N;
    vector<ll>  A(N);
    rep(i,N){
        cin >> A.at(i);
    }

    ll cnt = 0;
    ll bef = A.at(0);
    rep(i,N-1){
        if( bef > A.at(i+1)){
            cnt += (bef - A.at(i+1));
            A.at(i+1) = bef;
        }
        bef = A.at(i+1);
    }
    cout << cnt << endl;
    return 0;

}

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

using namespace std;
typedef long long ll;

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  vector<int> left(n, -1);
  vector<int> right(n, -1);

  int rest = -1;
  int cur = 0;
  for (int i = 0; i < n; ++i) {
    rest--;
    if (rest < 0 && s[i] == 'o') {
      left[i] = ++cur;
      rest = c;
      if (cur == k) break;
    }
  }

  rest = -1;
  cur = k;
  for (int i = n - 1; i >= 0; --i) {
    rest--;
    if (rest < 0 && s[i] == 'o') {
      right[i] = cur--;
      rest = c;
      if (cur == 0) break;
    }
  }

  for (int i = 0; i < n; ++i) {
    if (right[i] == left[i] && right[i] >= 0) {
      cout << i + 1 << '\n';
    }
  }
  return 0;
}



Measured memory_bytes: 3332
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


int main(){

    char v[4][4];

    for (int i = 0; i < 3; i++)
        scanf("%s", v[i] );
    printf("%c%c%c\n", v[0][0],v[1][1],v[2][2] );
return 0;
}


Measured memory_bytes: 128
from collections import deque
K=int(input())
Q=deque(list(range(1,10)))
for _ in range(K):
  x=Q.popleft()
  if x%10 != 0:
    Q.append(10*x+x%10-1)
  Q.append(10*x+x%10)
  if x%10 != 9:
    Q.append(10*x+x%10+1)
print(x)

Measured memory_bytes: 11908
using System.Linq;
using System;
using System.IO;

class Program
{
  static void Main(string[] args)
  {
    var line = Console.ReadLine().Split(' ');
    var a = int.Parse(line[0]);
    var b = int.Parse(line[1]);
    var k = int.Parse(line[2]);

    var sw = new StreamWriter(
              Console.OpenStandardOutput()
            ) { AutoFlush = false };

    if((k * 2) > b - a)
    {
      for(var i = a; i <= b; i++)
        sw.WriteLine(i);
    }
    else
    {
      for(var i = a; i < a + k; i++)
        sw.WriteLine(i);
      for(var i = b - k + 1; i <= b; i++)
        sw.WriteLine(i);
    }

    sw.Flush();
  }
}

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

int main() {
  string S;
  cin >> S;
  if (S=="SUN") {
    cout << 7 << endl;
  }
  else {
    if (S=="MON") {
      cout << 6 << endl;
    }
    else {
      if (S=="TUE") {
        cout << 5 << endl;
      }
      else {
        if (S=="WED") {
          cout << 4 << endl;
        }
        else {
          if (S=="THU") {
            cout << 3 << endl;
          }
          else {
            if (S=="FRI") {
              cout << 2 << endl;
            }
            else {
              cout << 1 << endl;
            }
          }
        }
      }
    }
  }
}

Measured memory_bytes: 3564
n = int(input())

l = [0]*4
w = ["AC","WA","TLE","RE"]

for i in range(n):
    s = input()
    if s == "AC":
        l[0] += 1
    elif s == "WA":
        l[1] += 1
    elif s == "TLE":
        l[2] += 1
    else:
        l[3] +=1
        
for i in range(4):
    print(w[i] + " x " + str(l[i]))

Measured memory_bytes: 9144
# CODE FESTIVAL 2016 B
N,A,B = list(map(int, input().split()))
cnt = 0
b_cnt = 0

S = input()
for s in S:
    if s == 'c':
        print('No')
    elif cnt >= A+B:
        print('No')
    elif s == 'b' and b_cnt >= B:
        print('No')
    else:
        cnt += 1
        if s == 'b':
            b_cnt += 1
        print('Yes')

Measured memory_bytes: 4016
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int a[n];
    repi(i, n, 0)
    {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a, a + n);
    ll mid = n & 1 ? a[n / 2] : (a[n / 2] + a[n / 2 - 1]) / 2;
    ll sum = INF;
    repi(i, mid + 1000, mid - 1000)
    {
        ll s = 0;
        repi(i, n, 0)
        {
            s += abs(a[i] - mid);
        }
        sum = min(sum, s);
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cassert>
#include <cstdint>
#include <functional>
#include <tuple>
#include <vector>

template <typename Abelian> class PotentializedUnionFindTree {

public:
	using value_type = Abelian;
	using reference = value_type &;
	using const_reference = const value_type &;
	using size_type = std::uint_fast32_t;

private:
	using F = std::function<value_type(const_reference, const_reference)>;
	using G = std::function<value_type(const_reference)>;
	const F f;
	const G g;
	const value_type neutral_;
	std::vector<std::tuple<bool, size_type, value_type>> tree;

public:
	PotentializedUnionFindTree(const size_type size,
		const_reference neutral = value_type(),
		const F &f = std::plus<value_type>(),
		const G &g = std::negate<value_type>())
		: f(f), g(g), neutral_(neutral),
		tree(size, std::forward_as_tuple(1, 1, neutral_)) {}
	size_type find(const size_type x) {
		assert(x < tree.size());
		if (std::get<0>(tree[x]))
			return x;
		const size_type t = std::get<1>(tree[x]);
		std::get<1>(tree[x]) = find(t);
		std::get<2>(tree[x]) = f(std::get<2>(tree[t]), std::get<2>(tree[x]));
		return std::get<1>(tree[x]);
	}
	value_type potential(const size_type x) {
		assert(x < tree.size());
		find(x);
		return std::get<2>(tree[x]);
	}
	value_type diff(const size_type x, const size_type y) {
		assert(x < tree.size());
		assert(y < tree.size());
		return f(potential(y), g(potential(x)));
	}
	bool unite(size_type x, size_type y, value_type d) {
		assert(x < tree.size());
		assert(y < tree.size());
		d = f(d, diff(y, x));
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (std::get<1>(tree[x]) < std::get<1>(tree[y]))
			std::swap(x, y), d = g(d);
		std::get<1>(tree[x]) += std::get<1>(tree[y]);
		tree[y] = std::forward_as_tuple(0, x, d);
		return true;
	}
	bool same(const size_type x, const size_type y) {
		assert(x < tree.size());
		assert(y < tree.size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < tree.size());
		return std::get<1>(tree[find(x)]);
	}
};

#include<iostream>
int main(void) {
	int n, m;
	std::cin >> n >> m;
	PotentializedUnionFindTree<int> T(n, 0);
	while (m--) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 2560
//  Created by liszt on 2019/07/21.
#include<bits/stdc++.h>
using namespace std;

int main(){
    string s; cin>>s;
    int a=0,b=0;
    for(int i=0;i<s.size();i++){
        if((i%2)^(s[i]=='1'))a++;
        else b++;
    }
    cout<<(a<b ? a : b)<<endl;
}

Measured memory_bytes: 512
import scala.io.StdIn._
object Main {
  def main(args:Array[String]) {
    val NM = readLine().split(' ').map(_.toInt)
    val H = readLine().split(' ').map(_.toLong)

    var flag = Array.fill(NM(0))(1)
    for(i <- 0 until NM(1)) {
      val AB = readLine().split(' ').map(_.toInt)
      if(H(AB(0) - 1) <= H(AB(1) - 1)) flag(AB(0) - 1) = 0
      if(H(AB(0) - 1) >= H(AB(1) - 1)) flag(AB(1) - 1) = 0
    }
    println(flag.sum)
  }
}



Measured memory_bytes: 65496
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 60 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int n ; ll k ;

struct mat {
	ll a[N][N] ;
	mat operator *(const mat &o) const {
		mat r = {} ;
		rep(i, 1, n) rep(k, 1, n) rep(j, 1, n)
		r.a[i][j] = (r.a[i][j] + a[i][k] * o.a[k][j]) % MOD ;
		return r ;
	}
} b, r ;

signed main(){
	scanf("%d%lld", &n, &k) ;
	rep(i, 1, n)
	rep(j, 1, n)
	scanf("%lld", &b.a[i][j]) ;
	rep(i, 1, n) r.a[i][i] = 1 ;
	for (; k; k >>= 1, b = b * b) if (k & 1) r = r * b ;
	ll ans = 0 ;
	rep(i, 1, n) rep(j, 1, n) ans = (ans + r.a[i][j]) % MOD ;
	printf("%lld\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
	int n, i, a[101];
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> a[i];
	for (i = n - 1; i >= 0; i--)
	{
		if (i == 0)cout << a[i];
		else cout << a[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3104
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int num, wk, tk, A, B;

	while( cin >> num )
	{
		if(!num) break;
		A = 0; B = 0;

		for(int i = 0; i < num; i++)
		{
			cin >> wk >> tk;
			if(wk > tk)
			{
				A += wk + tk;
			}
			else if(wk < tk) 
			{
				B += wk + tk;
			}
			else
			{
				A += wk;
				B += tk;
			}
		}

		printf("%d %d\n", A, B);
		
	}
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<char> vec(H * W);
  int a = 0;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> vec.at(a);
      a++;
    }
  }
  
  a = 0;
  
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    cout << '#';
    for (int j = 0; j < W; j++) {
      cout << vec.at(a);
      a++;
    }
    cout << '#' << endl;
  } 
  
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  
  cout << endl;
  
}

Measured memory_bytes: 3608
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1; i <= 3500; i++ {
		for j := 1; j <= 3500; j++ {
			x := n * i * j
			y := 4*i*j - n*i - n*j
			if y > 0 && x%y == 0 {
				fmt.Println(i, j, x/y)
				return
			}
		}
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	int a[1001],b[1001],sum[1001];
	int i,j;
	int max;
	int maxi;
	
	cin>>n>>m;
	for(i=1;i<=n;i++)	cin>>a[i];
	for(i=1;i<=m;i++)	cin>>b[i];
	for(i=1;i<=n;i++)	sum[i]=0;
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(a[j]<=b[i]){
				sum[j]++;
				break;
			}
		}
	}
	max=-1;
	for(i=1;i<=n;i++){
		if(max<sum[i]){
			max=sum[i];
			maxi=i;
		}
	}
	cout<<maxi<<endl;
	return 0;
}


Measured memory_bytes: 3120
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func rcvInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func rcvUint64() uint64 {
	sc.Scan()
	i, _ := strconv.ParseUint(sc.Text(), 10, 64)
	return i
}

func gcd(m, n uint64) uint64 {
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	a := new(big.Int).SetUint64(m)
	b := new(big.Int).SetUint64(n)
	return z.GCD(x, y, a, b).Uint64()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := rcvInt()

	a := make([]uint64, n)
	for i := 0; i < n; i++ {
		a[i] = rcvUint64()
	}

	y := a[0]
	for _, x := range a {
		y = gcd(x, y)
	}

	fmt.Println(y)
}


Measured memory_bytes: 5632
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, M; cin >> N >> M;
    map<ll, vpl> lm, rm;
    REP(i, M){
        ll r, l, d; cin >> r >> l >> d;
        lm[l].pb(PL(r, d));
        rm[r].pb(PL(l, -d));
    }
    vl xs(N+1, LINF); xs[0] = 0;
    vb chk(N, false);
    bool ok = true;
    FOR(i,1,N+1){
        if(ok == false) break;
        if(xs[i] < LINF) continue;
        queue<ll> q;
        q.push(i); xs[i] = 0;
        while(q.size() > 0){
            ll cur = q.front(); q.pop();
            if(chk[cur]){
                continue;
            }
            for(PL rp : lm[cur]){
                if(!chk[rp.ff]) q.push(rp.ff);
                if(xs[rp.ff] == LINF) xs[rp.ff] = xs[cur] + rp.ss;
                else if(xs[rp.ff] != xs[cur] + rp.ss){
                    ok = false; break;
                }
            }
            
            for(PL lp : rm[cur]){
                if(!chk[lp.ff]) q.push(lp.ff);
                if(xs[lp.ff] == LINF) xs[lp.ff] = xs[cur] + lp.ss;
                else if(xs[lp.ff] != xs[cur] + lp.ss){
                    ok = false; break;
                }
            }
            chk[cur] = true;
        }
    }
    ll xmax = 0, xmin = LINF;
    REP(i, N){
        xmax = max(xmax, xs[i]);
        xmin = min(xmin, xs[i]);
    }
    if(xmax - xmin > 1e9) ok = false;
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 27008
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 2e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    ll n=0;
    ll sum=0,cur=0;
    
    cin >> n;
    vector<int> A(n);
    rep(i,n){
        cin >> A[i];
    }
    for(int i=0; i<n-2; i++){
        if(A[i]+cur>A[i+1]){
            sum += A[i]+cur-A[i+1];
            cur = A[i]+cur-A[i+1];
            //cout << sum << "\n";
        }
        else{
            cur = 0;
        }
    }
    if(A[n-2]+cur>A[n-1]) sum += A[n-2]+cur-A[n-1];
    cout << sum << endl;
}

Measured memory_bytes: 3964
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int max = 0;
		int counter = 0;
		
		for(int i = 0; i < s.length(); ++i) {
		    if(s.charAt(i) == 'A' || s.charAt(i) == 'C' || s.charAt(i) == 'G' || s.charAt(i) == 'T'){
		        ++counter;
		        if(max < counter) max = counter;
		        else continue;
		    }
		    else counter = 0;
		}
		
		System.out.println(max);
	}
}

Measured memory_bytes: 23764
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long[] H = new long[N];
		
		HashMap<Long, Integer> hm = new HashMap<>();
		
		for(int i = 0; i < N; i++) {
			long l = sc.nextLong() - i;
			H[i] = l;
			if(!hm.containsKey(l))hm.put(l, 1);
			else hm.put(l, hm.get(l) + 1);
		}
		
		long count = 0;
		
		for(int i = 0; i < N - 1; i++) {
			hm.put(H[i], hm.get(H[i]) - 1);
			H[i] += i * 2;
			if(hm.containsKey(-H[i]))count += hm.get(-H[i]);
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 72968
#include<stdio.h>
main()
{
	int a,b,c,d,f,g;
	scanf("%d\n%d\n%d\n%d",&a,&b,&c,&d);
 f=b*c;
g=(a-b)*d;
if(a>=b){
	printf("%d\n",f+g);
}
else printf("%d\n",a*c);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N,T;
vector<int> p;
int main() {
  cin >> N >> T;
  p.resize(N);
  for (auto &val : p){
    cin >> val;
  }
  ll pre = p[0];
  ll t = p[0] + T;
  ll ans = 0;
  for (int i = 1; i < N; i++){
    //
    if (p[i] <= t){
      t = p[i] + T;
    }else{
      ans += t - pre;
      t = p[i] + T;
      pre = p[i];
    }
  }
  ans += t - pre;
  cout << ans << endl;
  return 0;
}


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

struct edge {
    int to;
    vector<int> from;
};

int main() {
    constexpr int inf = 1e4;

    int N, E, T;
    cin >> N >> E >> T;
    T--;
    vector<int> w(N);
    for(int i = 0; i < N; ++i) {
        cin >> w[i];
    }
    vector<edge> es(E);
    for(int i = 0; i < E; ++i) {
        int c;
        cin >> es[i].to >> c;
        es[i].to--;
        vector<int> from(c);
        for(int j = 0; j < c; ++j) {
            cin >> from[j];
            from[j]--;
        }
        es[i].from = move(from);
    }

    vector<int> dist(N, inf);
    for(int i = 0; i < N; ++i) {
        if(w[i] == 1) dist[i] = 1;
    }
    for(int cnt = 0; cnt < N; ++cnt) {
        for(auto& e : es) {
            vector<int> costs;
            for(auto v : e.from) {
                costs.push_back(dist[v]);
            }
            sort(rbegin(costs), rend(costs));
            int cost = 0;
            for(int i = 0; i < (int)costs.size(); ++i) {
                cost = max(cost, costs[i] + i);
            }
            dist[e.to] = min(dist[e.to], cost);
        }
    }

    cout << (dist[T] == inf ? -1 : dist[T]) << endl;
}



Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,a,b,c,d;
    cin >> A >> B;
    a = A+B;
    b = A-B;
    c = A*B;
    d = max(a,b);
    int answer = max(c,d);
    cout << answer << endl;
}


Measured memory_bytes: 256
S = input()

S = S[::-1]

index = 0
#possible = False

while index < len(S):
    if S[index] == 'm':
        if S[index:index+5] == 'maerd':
            index += 5
            continue
        else:
            break
    elif S[index] == 'e':
        if S[index:index+5] == 'esare':
            index += 5
            continue
        else:
            break
    elif S[index] == 'r':
        if S[index:index+6] == 'resare':
            index += 6
            continue
        elif S[index:index+7] == 'remaerd':
            index += 7
            continue
        else:
            break

if index == len(S):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	ll A[N];
	rep(i, N)
	{
		cin >> A[i];
	}

	sort(A, A+N, greater<ll>());

	ll x = 0, y = 0;
	int count = 0;

	for (int i = 0 ; i < N; i++)
	{
		if ((x != 0) && (y != 0))
		{
			break;
		}

		if (x == 0)
		{
			if ((i > 0) && (A[i] != A[i-1]))
			{
				if (count > 1)
				{
					x = A[i-1];
					if (count > 3)
					{
						y = A[i-1];
					}
					
				}
				count = 1;
			}
			else
			{
				count++;
			}

		}
		else
		{
			
			if (A[i] != A[i-1])
			{
				if (count > 1)
				{
					y = A[i-1];
				}
				count = 1;
			}
			else
			{
				count++;
				if ((i == N-1) && (count > 1))
				{
					y = A[i];
				}
			}
			
		}
	}
	//cout << x << " " << y << endl;
	cout << x * y << endl;

	
	return 0;
}


Measured memory_bytes: 1024
def smaller(x, y):
	if x < y: return x
	return y

N, K = map(int, input().split())
V = list(map(int, input().split()))
M = smaller(N, K)
max = 0
for i in range(0, M+1):
	for j in range(0, M+1-i):
		negative = []
		sum = 0
		for k in range(0, i):
			if V[k] < 0: negative.append(V[k])
			sum += V[k]
		for k in range(0, j):
			if V[-1-k] < 0: negative.append(V[-1-k])
			sum += V[-1-k]
		negative.sort()
		for k in range(0, smaller(len(negative), K-i-j)):
			sum -= negative[k]
		if max < sum: max = sum
print(max)

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

using namespace std;

typedef long long LL;

int N, M;
double t1 = 1900, t2 = 100;

void Solve()
{
  t1 *= M;
  double ans = 0;
  int a = (N - M) * t2;
  int p = 1 << M;
  double pp = 1;
  for (int i = 1; i <= 1000000; ++i) {
    ans += (a + t1) * i / p * pp;
    pp = pp * (p - 1) / p;
  }
  int ians = ans + 0.5;
  printf("%d\n", ians);
}

int main()
{
#ifdef linjian
freopen("in", "r", stdin);
#endif
  scanf("%d%d", &N, &M);
  Solve();
  return 0;
}

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

signed main()
{
  int X, A = 0;
  cin >> X;
  if(X % 11 >= 0) A++;
  if(X % 11 >= 7 || X % 11 == 0) A++;
  cout << (X - 1) / 11 * 2 + A << endl;
  return 0;
}


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

int main(){
  long n,m,ans=0,i;
  cin >> n >> m;
  if(n>=m){
    cout << 0; return 0;
  }
  vector<long> x(m);
  for(i=0; i<m; i++){
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  vector<long> y(m-1);
  for(i=0; i<m-1; i++){
    y[i]=x[i+1]-x[i];
  }
  sort(y.begin(), y.end());
  for(i=0; i<m-n; i++){
    ans+=y[i];
  }
  cout << ans;
  
}

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

int main(){
  int n,l;cin >> n >> l;
  int a[n],ans = 0,mini = 100000000,mi = 0;
  int all = 0;
  rep(i,n){
    int a = l+i;
    all += a;
    if(mini > abs(a)){mini = abs(a);mi = a;}
  }
  cout << all - mi << endl;
  return 0;
}


Measured memory_bytes: 256
H = 1
W = 1
while H and W:
    H, W = input().split()
    H = int(H)
    W = int(W)
    if H == 0\
    and W == 0:
        break

    for h in range(H):
        for w in range(W):
            if w == W - 1:
                print("#")
            else:
                print("#", end="")
    print()

Measured memory_bytes: 9124
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		
		int[][] curr   =new int[3][2];
		int[][] next   =new int[3][2];
		for(int i=0; i<3; i++)
			curr[i][0]=1;
		
		int[]   dayPlan=new int[N];
		for(int i=0; i<K; i++)
			dayPlan[sc.nextInt()-1] = sc.nextInt();
		
		for(int i=0; i<N-1; i++)
		{
			if(dayPlan[i] != 0)
			{
				for(int j=0; j<3; j++)
				{
					if(j != dayPlan[i]-1)
					{
						curr[j][0] = 0;
						curr[j][1] = 0;
					}
				}
			}
			for(int j=0; j<3; j++)
			{
				for(int k=0; k<3; k++)
					if(j==k){ next[k][1]+=curr[j][0]; next[k][1]%=10000; }
					else    { next[k][0]+=curr[j][0]; next[k][0]%=10000; }
				
				for(int k=0; k<3; k++)
					if(j!=k){ next[k][0]+=curr[j][1]; next[k][0]%=10000; }
			}
			
			for(int j=0; j<3; j++)
			{
				curr[j][0]=next[j][0];
				curr[j][1]=next[j][1];
				next[j][0]=0;
				next[j][1]=0;
			}
		}
		
		int ans = 0;
		for(int i=0; i<3; i++)
		{
			if(dayPlan[N-1]==0 || i==dayPlan[N-1]-1)
				ans += curr[i][0]+curr[i][1];
		}
		ans %= 10000;
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 19764