akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;
char s[100005];

int main()
{
    int i;

    while(scanf("%s",s) != EOF)
    {
        int len = strlen(s);
        for(i = 0;i < len;i += 2)
        {
            printf("%c",s[i]);
        }
        printf("\n");
    }

    return 0;
}


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

int main(){
  ll n,yen;
  cin >> n >> yen;
  
  for(int i=0; i<n+1; i++){
   for(int j=0; j<n+1-i; j++){
    for(int k=0; k<n+1-i-j; k++){
      ll nyen=10000*i+5000*j+1000*k;
      ll mai = i+j+k;
      if(mai==n && nyen==yen){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
   }
  }
  
  cout << -1 << " " << -1 << " " << -1 << endl;
  
  return 0;
  
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define MAXN 1000
using namespace std;

int w,h,n;
int x1[MAXN+5],y1[MAXN+5],x2[MAXN+5],y2[MAXN+5];
int fld[2*MAXN][2*MAXN];
int f[4][2]={{0,-1},{-1,0},{1,0},{0,1}};

int work(int *x,int *y,int t)
{
    vector <int> xx;
    for(int i=0;i<n;i++)
    {
        if(1<=x[i]&&x[i]<=t)
            xx.push_back(x[i]);
        if(1<=y[i]&&y[i]<=t)
            xx.push_back(y[i]);
    }
    xx.push_back(0);
    xx.push_back(t);
    sort(xx.begin(),xx.end());
    xx.erase(unique(xx.begin(),xx.end()),xx.end());
    for(int i=0;i<n;i++)
    {
        x[i]=find(xx.begin(),xx.end(),x[i])-xx.begin();
        y[i]=find(xx.begin(),xx.end(),y[i])-xx.begin();
    }
    return xx.size()-1;
}

int bfs()
{
    int ans=0;
    for(int j=0;j<h;j++)
        for(int i=0;i<w;i++)
        {
            if(fld[j][i])
                continue;
            ans++;
            queue <pair<int,int> > q;
            q.push(make_pair(i,j));
            while(!q.empty())
            {
                pair <int,int> t;
                t=q.front();
                q.pop();
                for(int i=0;i<4;i++)
                {
                    int nx=t.first+f[i][0];
                    int ny=t.second+f[i][1];
                    if(nx<0||ny<0||nx>w||ny>h)
                        continue;
                    if(fld[ny][nx]>0)
                        continue;
                    q.push(make_pair(nx,ny));
                    fld[ny][nx]=1;
                }
            }
        }
    return ans;
}

int main()
{
    while(1)
    {
        memset(fld,0,sizeof fld);
        scanf("%d%d",&w,&h);
        if(!w&&!h)
            break;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%d%d%d%d",&x1[i],&y1[i],&x2[i],&y2[i]);
        w=work(x1,x2,w);
        h=work(y1,y2,h);
        //printf("*%d %d\n",w,h);
        for(int i=0;i<n;i++)
        {
            fld[y1[i]][x1[i]]++;
            fld[y1[i]][x2[i]]--;
            fld[y2[i]][x1[i]]--;
            fld[y2[i]][x2[i]]++;
        }
        for(int i=0;i<h;i++)
            for(int j=1;j<w;j++)
                fld[i][j]+=fld[i][j-1];
        for(int i=1;i<h;i++)
            for(int j=0;j<w;j++)
                fld[i][j]+=fld[i-1][j];
        printf("%d\n",bfs());
    }
    return 0;
}

Measured memory_bytes: 18360
n = gets.to_i
s = gets.split.map(&:to_i)
$co = 0

class Array
  def merge_sort
    merge = ->(a, b) {
      result = []
      while a.size > 0 and b.size > 0
        result << if a[0] < b[0]
          a.shift
        else
          $co += a.size
          b.shift
        end
      end
      result + a + b
    }
    
    l = length
    return self if l <= 1
    q = l / 2
    merge.(self[0...q].merge_sort, self[q..-1].merge_sort)
  end
end

s.merge_sort
puts $co


Measured memory_bytes: 44152
#include <iostream>
#include <vector>

int main() {
    std::vector<int> v;
    std::vector<bool> c(10001, false);
    v.push_back(0);
    c[0] = true;
    size_t ss = 1;

    int n; std::cin >> n;
    for (int i = 0; i < n; i++) {
        int va; std::cin >> va;
        size_t sss = ss;
        for (size_t j = 0; j < sss; j++) {
            auto nv = v[j] + va;
            if (!c[nv]) {
                c[nv] = true;
                ss++;
                v.push_back(nv);
            }
        }
    }

    for (int i = c.size() - 1; i >= 0; i--) {
        if (c[i] && i % 10 != 0) {
            std::cout << i << std::endl;
            return 0;
        }
    }
    std::cout << 0 << std::endl;
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, m, s = LI()
s = min(s, 2500)
uvab = [LI() for _ in range(m)]
cd = [LI() for _ in range(n)]
dp = [[inf]*(2500+1) for _ in range(n+1)]
dp[0][s] = 0
edges = [[] for _ in range(n)]
exchange = [[c,d] for c,d in cd]
for u,v,a,b in uvab:
    edges[u-1].append((v-1, a, b))
    edges[v-1].append((u-1, a, b))
for i, (c,d) in enumerate(cd):
    edges[i].append((i, -c, d))

h = [(0, 0, s)]
while h:
    dist, u, coin = heappop(h)
    if dp[u][coin] < dist:
        continue
    for v, a, b in edges[u]:
        if 2500 >= coin-a >= 0:
            if dp[u][coin] + b < dp[v][coin-a]:
                dp[v][coin-a] = dp[u][coin] + b
                heappush(h,(dp[v][coin-a], v, coin-a))

for i in range(1,n):
    print(min(dp[i]))

Measured memory_bytes: 97644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
 
        String[] str = scan.nextLine().split(" ");
        
        int n = Integer.valueOf(str[0]);
        int m = Integer.valueOf(str[1]);
        
        if (n == m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] t = new int[n];
        for(int i=0; i<n; i++){
            t[i] = sc.nextInt();
        }
        int m = sc.nextInt();
        for(int j=0; j<m; j++){
            int[] standardTimes = t.clone();
            int drinkNum = sc.nextInt();
            int drinkTime = sc.nextInt();
            standardTimes[drinkNum - 1] = drinkTime;
            int result = 0;
            for(int time : standardTimes){
                result += time;
            }
            System.out.println(result);
        }



    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 21204
#include <stdio.h>

int main(){
  int i, N, X, m, sum=0, min;
  scanf("%d %d", &N, &X);
  for(i=0;i<N;i++){
    scanf("%d",&m);
    if(i==0) min=m;
    sum+=m;
    if(min>m) min=m;
  }
  printf("%d\n", N+(X-sum)/min);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    string S;
    ll K;
    cin >> S >> K;
    ll cnt = 0;
    ll sub = 0;
    bool same = false;
    if(S[0] == S[(int)S.size()-1]){
        ll a=1;
        ll b=1;
        REP(i,S.size()-1){
            if(S[i] == S[i+1]){
                a++;
            }else{
                break;
            }
        }
        for(int i=(int)S.size()-1; i>0; i--){
            if(S[i] == S[i-1]){
                b++;
            }else{
                break;
            }
        }
        if(a != (int)S.size()){
            sub = a/2+b/2-(a+b)/2;
            sub *= K-1;
        }else{
            same = true;
        }
    }
    REP(i,S.size()-1){
        if(S[i] == S[i+1]){
            S[i+1] = 'A';
            cnt++;
        }
    }
    if(same){
        cout << (((int)S.size()*K)/2) << endl;
    }else{
        cout << (cnt*K-sub) << endl;
    }
}

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

#define ll long long
#define endl "\n"

const ll INF = 2e18;

int n;
vector <int> slimes(405, 0);	

ll sum (int l, int r){
	ll sum = 0;
	for (int i=l; i<=r; i++){
		sum += slimes[i];
	}

	return sum;
}

int main ()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll
	
	cin >> n;
	
	for (int i=1; i<=n; i++) cin >> slimes[i];

	vector <vector <int> > dp(n+1, vector <int> (n+1, INF));
	
	for (int left = n; left >= 1; left--){
		for (int right = 1; right <= n; right++){
			if (right < left) continue;
			if (left == right){
				dp[left][left] = 0;
				continue;
			}
			int summation = sum(left, right);
			for (int i=left; i<=right-1; i++){
				dp[left][right] = min(dp[left][right], dp[left][i] + dp[i+1][right] + summation);
			}
		}
	}

	cout << dp[1][n] << endl;

	return 0;
	
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

void solve() {
	int n; scanf("%d", &n);
	n = sqrt(n);
	printf("%d", n*n);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

#define MAX 22
#define INV (0)
#define REP(i,a,e) for(int i=(a); i<=(e); ++i)

void dfs(int map[][MAX], int i, int j, int &ans)
{
	const int di[] = {-1,0,1,0};
	const int dj[] = {0,1,0,-1};
	if( map[i][j] == INV || map[i][j] == '#' ){
		return ;
	}
	if( map[i][j] == '.' ){
		++ans;
		map[i][j] = '#';
	}
	for(int k = 0; k < 4; ++k){
		dfs( map, i + di[k], j + dj[k], ans );
	}
}

int main()
{
	while(true){
		int si, sj;
		int ans = 1;
		int map[MAX][MAX] = {{INV,},};
		int W,H;

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

		if( W == 0 && H == 0 ) break;

		REP(i,1,H){
			char c;
			scanf("%c", &c);
			REP(j,1,W){
				scanf("%c", &c);
				map[i][j] = c;
				if( map[i][j] == '@' ){
					si = i;
					sj = j;
				}
			}
		}

		dfs(map,si,sj,ans);

		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n; cin >> n; int cnt = 0;
    for(int i=1; i<=n; i++){
        int a, b; cin >> a >> b;
        if(a == b){
            if(++cnt == 3){ cout << "Yes"; return 0; }
        }
        else cnt = 0;
    }
    cout << "No";
}

Measured memory_bytes: 3632
# Segment tree
class SegmentTree():
    _data = []
    _offset = 0
    _size = 0

    def __init__(self, size):
        _size = size
        t = 1
        while t < size:
            t *= 2
        self._offset = t - 1
        self._data = [0 for _ in range(t * 2 - 1)]

    def update(self, index, value):
        i = self._offset + index
        self._data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            self._data[i] = self._data[i * 2 + 1] + self._data[i * 2 + 2]

    def query(self, start, stop):
        result = 0
        l = start + self._offset
        r = stop + self._offset
        while l < r:
            if l & 1 == 0:
                result = result + self._data[l]
            if r & 1 == 0:
                result = result + self._data[r - 1]
            l = l // 2
            r = (r - 1) // 2
        return result


N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])
st = SegmentTree(N - 1)

result = 0
for a, b in ab:
    a, b = a - 1, b - 1
    if st.query(a, b) != 0:
        continue
    result += 1
    st.update(b - 1, 1)
print(result)


Measured memory_bytes: 32272
import sys
input = sys.stdin.readline
n, a, b = [int(x) for x in input().split()]

sum = 0
for k in range(n+1):
    orik = k
    ksum = 0
    while k > 0:
        last = k % 10
        k = int(k/10)
        ksum += last
    if a <= ksum <= b:
        sum += orik
print(sum)

Measured memory_bytes: 39408
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner cin=new Scanner(System.in);
		
		while(true) {
			int H=cin.nextInt(),W=cin.nextInt();
			if(H==0 && W==0)break;
			for(int i=0;i<H;i++) {
				for(int j=0;j<W;j++) {
					if((i!=0 && i!=H-1) && (j!=0 && j!=W-1))System.out.print('.');
					else System.out.print('#');
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}

	}

}



Measured memory_bytes: 35964
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n  = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			count += (r - l) + 1;
		}

		out.println(count);
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define inv(x) qpow(x,mod-2)
using namespace std;
typedef long long ll;

const int N = 5e4+1;
const ll mod = 998244353;
const ll G = 3;
const double pi = acos(-1);

char a1[N],b1[N];
int x,y;
ll rev[N],fac[N],r[N];
ll a[N],b[N],c[N],d[N];

int qpow(ll a,int b)
{
	ll ret=1;
	while(b)
	{
		if(b&1)ret=(ret*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return ret;
}

void pre()
{
	ll i;
	for(i=1,fac[0]=1;i<N;++i)fac[i]=(fac[i-1]*i)%mod;
	for(rev[N-1]=inv(fac[N-1]),i=N-2;i>=0;--i)rev[i]=(rev[i+1]*(i+1))%mod;
}

inline void ntt(ll *a,int f,ll n)
{
    for(int i=0;i<n;i++)if(i<r[i])swap(a[i],a[r[i]]);
    for(int i=1,t=1;i<n;i<<=1,++t)
    {
        ll wn=qpow(G,(mod-1)/(1<<t));
        if(f==-1) wn=inv(wn);
        for(int j=0;j<n;j+=(i<<1))
        for(ll k=0,w=1;k<i;k++,w=w*wn%mod)
        {
            ll x=a[j+k],y=a[j+k+i]*w%mod;
            a[j+k]=(x+y)%mod;a[j+k+i]=(x-y+mod)%mod;
        }
    }
}

void NTT(ll *a,ll *b,ll len,bool tag)
{
	ll n=1,m=0;
	while(n<=2*len)n<<=1,m++;
	for(int i=0;i<n;++i)r[i]=r[i>>1]>>1|(1&i)<<(m-1);
	copy(a,a+x+1,c);copy(b,b+x+1,d);
	for(int i=x+1;i<N;++i)a[i]=b[i]=c[i]=d[i]=0;
	ntt(c,1,n);ntt(d,1,n);
	for(int i=0;i<n;++i)(c[i]*=d[i])%=mod;
	ntt(c,-1,n);ll t=inv(n);
	for(int i=0;i<=len;++i)a[i]=c[i]*t%mod;
	return;
}

/*

1101011011110
0111101011101

*/

int main()
{
	pre();
	scanf("%s%s",a1+1,b1+1);
	int len=strlen(a1+1);
	for(int i=1;i<=len;++i)
	if(b1[i]=='1'&&a1[i]=='1')x++;
	else if(a1[i]=='1')y++;
	a[0]=1;
	for(int i=0;i<=x;++i)b[i]=rev[i+1];
	for(int t=y;t;t>>=1)
	{
		for(int i=x+1;i<N;++i)a[i]=b[i]=c[i]=d[i]=0;
		if(t&1)NTT(a,b,x,0);
		NTT(b,b,x,1);
	}
	ll ans=0;
	for(int i=0;i<=x;++i)(ans+=a[i]*fac[x]%mod*fac[y]%mod*fac[x+y])%=mod;
	cout<<ans;
}

Measured memory_bytes: 2816
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

struct food
{
	int f, w, s;
};
struct Sorter
{
	bool operator()(const food& a, const food& b)
	{
		return a.f < b.f;
	}
};
int main()
{
	char name[10][32];
	int n;
	while (scanf("%d", &n), n)
	{
		food foods[10];
		for (int i = 0; i < n; ++i)
		{
			int w, s;
			scanf("%s %d %d", name[i], &w, &s);
			foods[i].f = i;
			foods[i].w = w;
			foods[i].s = s;
		}

		const double Inf = 1e12;
		double minG = Inf;
		int order[10];
		do
		{
			int sumW = 0;
			double g = 0;
			bool ok = true;
			for (int i = 0; i < n; ++i)
			{
				if (sumW > foods[i].s)
				{
					ok = false;
					break;
				}
				sumW += foods[i].w;
				g += (n-i) * foods[i].w;
			}
			g /= sumW;
			if (ok && g < minG)
			{
				minG = g;
				for (int i = 0; i < n; ++i)
					order[i] = foods[i].f;
			}
		} while (next_permutation(foods, foods+n, Sorter()));
		for (int i = n-1; i >= 0; --i)
			printf("%s\n", name[order[i]]);
	}

	return 0;
}

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

int gcd(int big,int small){
	//if(big<small)swap(big,small);
	int amari = big%small;
	while(amari!=0){
		big = small;
		small = amari;
		amari = big%small;
	}
	return small;
}
int main(void){
	int N,ans=0,temp;
	cin >> N;
	int A[N];
	for(int i=0;i<N;i++)cin >>A[i];
	int leftgcd[N];//左からi番目までのgcd
	int rightgcd[N];//右からi番目までのgcd
	leftgcd[0]=A[0];
	rightgcd[0]=A[N-1];
	for(int i=1;i<N;i++){
		leftgcd[i] = gcd(leftgcd[i-1],A[i]);
	}
	for(int i=1;i<N;i++){
		rightgcd[i] = gcd(rightgcd[i-1],A[(N-1)-i]);
	}
	//あとは地点iから左のgcdと右のgcdのgcdを求める
	for(int i=0;i<=N-1;i++){
		if(i==0){
			temp = rightgcd[N-1-1];
		}else if(i==(N-1)){
			temp = leftgcd[N-2];
		}else{
			temp= gcd(leftgcd[i-1],rightgcd[N-2-i]);
		}
		if(temp>ans)ans=temp;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1408
import sys
from collections import deque

input = sys.stdin.readline


def solve(H, W, A):
    WALL = - 10 ** 7
    dist = [[WALL] + [-1] * W + [WALL] for _ in range(H + 2)]
    dist[0] = dist[-1] = [WALL] * (W + 2)

    queue = deque()
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                dist[h + 1][w + 1] = 0
                queue.append((h + 1, w + 1))

    while queue:
        h, w = queue.popleft()
        d = dist[h][w]
        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            y, x = h + i, w + j
            if dist[y][x] == -1:
                dist[y][x] = d + 1
                queue.append((y, x))

    res = max(map(max, dist))
    return res


def main():
    H, W = map(int, input().split())
    A = [None] * H
    for i in range(H):
        A[i] = list(input().rstrip())

    ans = solve(H, W, A)
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
	int a,b,c; cin >> a >> b >> c;
	int k; cin >> k;
	while (k > 0) {
		if (c <= b) c *= 2;
		else if (b <= a) b *= 2;
		k -= 1;
	}
	if (c > b && b > a) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
int A,B,C;
cin>>A>>B>>C;
bool flag=false;
for(int i=0;i<100;i++){
    if(i*A%B==C){
        flag=true;
        break;
    }
    else {
        continue;
    }
}
if(flag){
    cout<<"YES"<<endl;
}
else{
    cout<<"NO"<<endl;
}
}

Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int n, m;

bool testCand(long long cand) {
    if ((long long)n * cand <= m) {
        if ((m % (n * cand)) % cand == 0)
            return true;
    }
    return false;
}

int main(void) {
	// in = fopen("D.in", "rt");
	
	fscanf(in, "%d %d", &n, &m);
	int ans = 1;
	for (int d = 1; d * d <= m; d++) {
	    if (m % d == 0) {
	        if (testCand(d))
	           ans = max(ans, d);
	        if (testCand(m / d))
	           ans = max(ans, m / d);
        }
    }
    fprintf(out, "%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;
    string ans;
    for(int i = 0; i < n; i++) {
        ans += s1[i];
        ans += s2[i];
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
 
#define NIL -2000000001
 
struct Node {
    int key;
    int parent = NIL;
    int left = NIL;
    int right = NIL;
};
 
 int root = NIL;
Node tree[500000];
 
void preorder(int s) {
    if (s != NIL) {
        cout << " " << tree[s].key;
        if (tree[s].left != NIL) {
            preorder(tree[s].left);
        }
        if (tree[s].right != NIL) {
            preorder(tree[s].right);
        }
    }
}
 
void inorder(int s) {
    if (s != NIL) {
        if (tree[s].left != NIL) {
            inorder(tree[s].left);
        }
        cout << " " << tree[s].key;
        if (tree[s].right != NIL) {
            inorder(tree[s].right);
        }
    }
}
 
void insert(int s) {
    int y = NIL;
    int x = root;
 
    while (x != NIL) {
        y = x;
        if (tree[s].key < tree[x].key) {
            x = tree[x].left;
        }
        else {
            x = tree[x].right;
        }
    }
    tree[s].parent = y;

    if (root == NIL) {
        root = s;
        return;
    }
 
    if (tree[s].key < tree[y].key) {
        tree[y].left = s;
    }
    else {
        tree[y].right = s;
    }
}
 
int find(int s, int v) {
    if (v == tree[s].key) {
        return s;
    }
    else if (v < tree[s].key) {
        if (tree[s].left == NIL) {
            return NIL;
        }
        find(tree[s].left, v);
    }
    else {
        if (tree[s].right == NIL) {
            return NIL;
        }
        find(tree[s].right, v);
    }
}

void _delete(int v) {
    int s = find(0, v);
    if (s == 0) {
        return;
    }

    if (tree[s].left == NIL && tree[s].right == NIL) {

    }
}
 
int main() {
    int n, value;
    string str;
 
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> str;
        if (str == "insert") {
            cin >> value;
            tree[i].key = value;
            insert(i);
        }
        else if (str == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
        else if (str == "find") {
            cin >> value;
            if (find(root, value) != NIL) {
                cout << "yes" << endl;
            }
            else {
                cout << "no" << endl;
            }
        }
        else if (str == "delete") {
            cin >> value;
            _delete(value);
        }
    }
 
    return 0;
}

Measured memory_bytes: 10980
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 0x3f3f3f3f;
int solve(int x)
{
    int cnt = 0;
    while(x > 0)
    {
        x /= 10;
        cnt++;
    }
    return cnt;
}
int main()
{
    ll n; cin >> n;
    for(int i = sqrt(n); i > 0; i--)
    {
        if(n % i == 0)
        {
            cout << max(solve(i),solve(n/i)) << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
s
k

s 100
k 10^18
 */
string s;
ll k;

int main(){
  cin>>s>>k;
  k--;

  int i=0;
  for(; s[i] == '1'; i++);
  LOG("i=%d, s[i]=%c\n", i, s[i]);
  
  if(i <= k)
    cout<< s[i] << endl;
  else
    cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

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

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>

using namespace std;
int n,m;
int p1[210000],p2[210000];
int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		if (x==1) p1[y]=1;
		if (y==n) p2[x]=1;
	}
	for (int i=1;i<=n;i++)
		if (p1[i]&&p2[i])
		{
			printf("POSSIBLE\n");
			return 0;
		}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  bool res = true;
  for(int i = 0;i < 3;i++){
    if(s[i] == s[i + 1])res = false;
  }
  if(res)cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static long solve(int m, long[][] dcs) {
    long answer = -1;
    long sum = 0;
    for (long[] dc : dcs) {
      long d = dc[0];
      long c = dc[1];
      sum += d * c;
      answer += c;
    }
    while (sum >= 10) {
      answer += sum / 10;
      sum = (sum % 10) + (sum / 10);
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int m = reader.nextInt();
    long[][] dcs = reader.nextLong(m, 2);
    out.println(solve(m, dcs));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 53500
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    vector<PLL> a;
    REP(i,n){
        LL x;
        cin>>x;
        a.PB(MP(x, i+1));
    }
    SORT(a);
    REP(i,n){
        cout<< a[i].second << " ";
    }
}

Measured memory_bytes: 2544
import sys

def solve():
    N, T = map(int, input().split())
    ts = [int(i) for i in input().split()]

    cur = ts[0]
    ans = 0

    for ti in ts[1:]:
        ans += min(T, ti - cur)
        cur = ti

    ans += T

    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 25196
args = [input() for _ in range(2)]

n = int(args[0])
h = [int(a) for a in args[1].split()]

if n == 1:
  print(0)
else:
  st = 0
  val = h[st]
  max_len = 0
  for i in range(1, n):
    next_val = h[i]
    if val < next_val:
      max_len = max(max_len, i - st -1)
      if i + max_len >= n:
        break
      st = i
    val = next_val
  
  if i == n - 1:
    max_len = max(max_len, n - 1 - st)
  
  print(max_len)

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

const int inf=1e9+10;

typedef pair<int,int> ii;

#define X first
#define Y second

const int N=3e5+10;
int a[N];
int main(){
  int n,k;
  cin>>k>>n;
  if (k%2==0){
    cout<<k/2<<" ";
    for(int i=2;i<=n;i++) cout<<k<<" ";
    return 0;
  }else{
    for(int i=1;i<=n;i++) a[i]=k/2+1;
    int n1=n;
    for(int i=1;i<=n-1-(n-1)/2;i++){
      if (a[n1]==1) n1--;
      else {
        a[n1]--;
        while (n1<n) a[++n1]=k;
      }
    }
    for(int i=1;i<=n1;i++) cout<<a[i]<<" ";
  }
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>
#include <queue>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


int main() {
  string S; cin >> S;
  int N = S.size();

  if (S[0] != '1' || S[N-1] != '0') {
    cout << "-1\n";
    return 0;
  }
  queue<int> q;
  rep(i, N-1) {
    if (S[i] != S[N-2-i]) {
      cout << "-1\n";
      return 0;
    }
    if (S[i] == '1')
      q.push(i);
  }
  q.push(N-1);
  rep(i, N-1) {
    while (!q.empty() && i >= q.front()) q.pop();
    cout << (i+1) << " " << q.front() + 1 << endl;
  }


  return 0;
}
// -> 1から連続するlまでが1、N-lまでが0、N-lからN-1が1、次が0


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

struct event{
    // eve: 0:封鎖開始  1:封鎖終了  2:出発
    // 封鎖は相対時間で(xiの距離を考慮)
    int eve,time,x;
};

bool operator<(const event& z,const event& y){
   return (z.time==y.time?z.eve < y.eve:z.time < y.time);//>で昇順
}

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

    multiset<int> place;
    vector<event> ev;
    
    for(int i = 0;i < n;i ++){
        int s,t,x;
        cin >> s >> t >> x;
        ev.push_back({0,s-x,x});
        ev.push_back({1,t-x,x});
    }
    for(int i = 0;i < q;i ++){
        int d;
        cin >> d;
        ev.push_back({2,d,-1});
    }
    sort(ev.begin(),ev.end());
    for(int i = 0;i < ev.size();i ++){
        if(ev[i].eve==0){
            place.insert(ev[i].x);
        }else if(ev[i].eve==1){
            place.erase(place.find(ev[i].x));
        }else{
            if(place.size()) cout << *place.begin() << endl;
            else cout << -1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 18792
S = input()
SSub = []
maxl = 0
for h in range(len(S)):
  for t in range(1,len(S)-h+1):
    if(h+t >= len(S)):
      SSub = S[h:]
    else:
      SSub = S[h:h+t]
    if len(SSub) == SSub.count("A") + SSub.count("T") + SSub.count("G") + SSub.count("C"): 
      if maxl < len(SSub):
        maxl = len(SSub) 
print(maxl)

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



int main(void){
    
    int K;
    cin >> K;
    
    int sum = 0;
    for(int i = 1; i <= K ; i++){
        
         for(int j = 1; j <= K ; j++){
             
              for(int k = 1; k <= K ; k++){
                 
                sum += gcd(gcd(i,j),k);
                  
              }
         }
         
        
        
    }
    
    cout << sum<<endl;
    

}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
	int x, y;
	cin >> x >> y;
	int f = 0;
	for(int i = 0; i <= x; i++){
		int a = y - 2 * i;
		int b = x - i;
		if(a - 4 * b == 0){
			f++;
			break;
			}
		}
		
	if(f == 0) {
		cout << "No";
		}
	else{
		cout << "Yes";
		}
		
	}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	string s;
	cin >>n >>s >>q;
	
	vector<VI> zt(26);
	rep(i, n) zt[s[i]-'a'].push_back(i);
	
	rep(zq,q){
		int x; cin >>x;
		if(x==1){
			int y; char z; cin >>y >>z;
			y--;
			if(s[y]==z) continue;
			auto it = lower_bound(all(zt[s[y]-'a']), y);
			//assert(it != zt[s[y]-'a'].end());
			zt[s[y]-'a'].erase(it);
			auto it2 = lower_bound(all(zt[z-'a']), y);
			zt[z-'a'].insert(it2, y);
			s[y] = z;
		}else{
			int l,r; cin >>l >>r;
			l--; r--;
			ll ans = 0;
			rep(j ,26){
				int sm = upper_bound(all(zt[j]), r) -lower_bound(all(zt[j]), l);
				if (sm > 0) ans++;
			}
			cout << ans <<"\n";
		}
	
	
	
	}

	return 0;
}


Measured memory_bytes: 3868
n, m = map(int, input().split())
dp = [0]*(n+1)
dp[0] = 1
m_list = [int(input()) for _ in range(m)]
for i in range(1,n+1):
  if i==1:
    if m_list and i==m_list[0]:
      m_list.pop(0)
      dp[i]=0
    else:
      dp[i]=1
  elif m_list and i == m_list[0]:
    m_list.pop(0)
    dp[i] = 0
  else:
    dp[i] = (dp[i-1]+dp[i-2])% 1000000007
print(dp[-1])

Measured memory_bytes: 13616
#include"stdio.h"
#include<stdlib.h>

int top, A[1000];

void push(int n)
{
	A[++top] = n;
	return;
}

int pop()
{
	--top;
	return A[top+1];
}

int main()
{
	int a, b;
	top = 0;
	char str[100] = { '\0' };

	while (scanf("%s", str) != EOF)
	{
		if (str[0] == '+')
		{
			a = pop();
			b = pop();
			push(a+b);
		}
		else if (str[0] == '-')
		{
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (str[0] == '*')
		{
			a = pop();
			b = pop();
			push(a * b);
		}
		else
			push(atoi(str));
	}

	printf("%d\n", pop());

	return 0;
}


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

string s, t, res;
int dp[3005][3005];

int solve(int a, int b){
    if(a >= s.size() || b >= t.size()) return dp[a][b] = 0;
    if(dp[a][b] != -1) return dp[a][b];
    int r1 = solve(a+1, b);
    int r2 = solve(a, b+1);
    int r3 = s[a] == t[b] ? solve(a+1, b+1)+1 : 0;
    return dp[a][b] = max(r1, max(r2,r3));
}

void rebuild(int a, int b){
    if(a >= s.size() || b >= t.size()) return;
    int r1 = dp[a+1][b];
    int r2 = dp[a][b+1];
    // int r3 = s[a] == t[b] ? dp[a+1][b+1] + 1 : 0;
    if(dp[a][b] == r1) rebuild(a+1, b);
    else if(dp[a][b] == r2) rebuild(a, b+1);
    else res += s[a], rebuild(a+1, b+1);
}

int main(){
    memset(dp, -1, sizeof dp);
    cin >> s >> t;
    if(solve(0,0) == 0){
        string weiss = "";
        cout << weiss << endl;
        return 0;
    }
    rebuild(0,0);
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 35968
N, X, M = map(int, input().split())
ans = X
ALL_cal = [False] * M
ALL = []
rou = False
for i in range(N-1):
    X = pow(X, 2, M)
    if ALL_cal[X]:
        num = ALL_cal[X]
        now = i
        rou = True
        break
    ALL.append(X)
    ALL_cal[X] = i
    ans += X
if rou :
    roupe = now - num 
    nokori = N - now - 1
    print(sum(ALL[num:])*(nokori//roupe) + ans + sum(ALL[num:num + nokori%roupe]))
else:
    print(ans)

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>s;
	for(int i=0; i<=2; i++){
		if(s[i]=='7'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>

using namespace std;

const int N = 18;

int mx[2][1 << N];

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		int x;
		cin >> x;
		for (int m = i; m < (1 << n); m = (m + 1) | i) {
			if (mx[0][m] < x) {
				mx[1][m] = mx[0][m];
				mx[0][m] = x;
			}
			else if (mx[1][m] < x) {
				mx[1][m] = x;
			}
		}
	}
	int cur = 0;
	for (int i = 1; i < (1 << n); i++) {
		cur = max(cur, mx[0][i] + mx[1][i]);
		cout << cur << ' ';
	}
}

Measured memory_bytes: 5680
#include<stdio.h>
long n,i,j,ans,year,month,day;
int main(void)
{
  scanf("%d",&n);
  for (i=1;i<=n;i++)
  {
    ans=0;
    scanf("%d%d%d",&year,&month,&day);
    if ((year%3==0)||(month%2==1)) ans=ans+21-day;else ans=ans+20-day;
    month=month+1;
    if (month<=10)
    {
      for (j=month;j<=10;j++)
        if ((year%3==0)||(j%2==1)) ans=ans+20;else ans=ans+19;
    }
    year=year+1;
    for (j=year;j<=999;j++)
      if (j%3==0) ans=ans+200;else ans=ans+195;
    printf("%d\n",ans);
  }
  return 0;
}   

Measured memory_bytes: 0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
As = list(map(int, input().split()))

inc = None
prev = None
ans = 0
for i, a in enumerate(As):
    if i == 0:
        ans += 1
    elif inc is None:
        if a > prev:
            inc = True
        elif a < prev:
            inc = False
    else:
        if (inc and a < prev) or (inc == False and a > prev):
            ans += 1
            inc = None
    prev = a
print(ans)


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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int dp[1000][5];

int main() {
    string s;
    Int k;
    cin >> s >> k;
    Int n = s.size();
    dp[0][0] = 1;
    Int cnt = 0;
    for (Int i = 0; i < (Int)n; i++) {
        for (Int j = 0; j <= (Int)k; j++) {
            dp[i + 1][j] += dp[i][j];
        }
        for (Int j = 0; j < (Int)k; j++) {
            if (cnt == j) {
                dp[i + 1][j + 1] += (dp[i][j] - 1) * 9 + s[i] - '0';
            } else {
                dp[i + 1][j + 1] += dp[i][j] * 9;
            }
        }
        if (s[i] != '0') cnt++;
    }
    // for (Int i = 0; i < (Int)4; i++) {
    //     for (Int j = 0; j <= (Int)n; j++) {
    //         cout << dp[j][i] << " ";
    //     }
    //     cout << endl;
    // }
    print(dp[n][k]);
    return 0;
}

Measured memory_bytes: 256