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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	int time = H2*60+M2-H1*60-M1;
	cout << time - K << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    int ans = 0;
    for(int i = 0; i <= N-1; i++){
        if(p[i] == i+1){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool p_judge(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	ll N, A[55], mini = 1000005, maxi = -1000005, mininum, maxinum;

	cin >> N;
	for (int i = 1; i <= N; i++) {

		cin >> A[i];

		if (mini > A[i]) {

			mini = A[i];
			mininum = i;

		}
		if (maxi < A[i]) {

			maxi = A[i];
			maxinum = i;

		}

	}

	if (mini == 0 && maxi == 0) {

		cout << 0 << endl;

	}
	else if (mini >= 0) {

		cout << N - 1 << endl;
		for (int i = 1; i < N; i++) {

			cout << i << SPACE << i + 1 << endl;

		}

	}
	else if (maxi <= 0) {

		cout << N - 1 << endl;
		for (int i = N; i > 1; i--) {

			cout << i << SPACE << i - 1 << endl;

		}

	}
	else if (maxi + mini >= 0) {

		cout << N * 2 - 1 << endl;
		for (int i = 1; i <= N; i++) {

			cout << maxinum << SPACE << i << endl;

		}
		for (int i = 1; i < N; i++) {

			cout << i << SPACE << i + 1 << endl;

		}

	}
	else {

		cout << N * 2 - 1 << endl;
		for(int i = 1; i <= N; i++) {

			cout << mininum << SPACE << i << endl;

		}
		for (int i = N; i > 1; i--) {

			cout << i << SPACE << i - 1 << endl;

		}

	}

	return 0;
}

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

int main(void)
{
	int n, m;

	std::cin >> n >> m;

	std::vector<std::vector<int> > v(n);

	for (int i = 0; i < m; i++) {
		int a, b;
		std::cin >> a >> b;

		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	std::stack<int> s;
	for (int i = 0; i < n; i++) {
		std::vector<bool> visited(n, false);
		s.push(i);
		visited[i] = true;
		while (v[s.top()].size() > 0) {
			int count = 0;
			bool r = false;
			for (size_t j = 0; j < v[s.top()].size(); j++) {
				if (!visited[v[s.top()][j]]) {
					visited[v[s.top()][j]] = true;
					s.push(v[s.top()][j]);
					r = true;
					break;
				} else {
					count++;
				}
			}
			if (!r && count == v[s.top()].size()) {
				break;
			}
		}
		std::stack<int> ss;
		while(!s.empty()) {
			ss.push(s.top());
			s.pop();
		}
		while (v[ss.top()].size() > 0) {
			int count = 0;
			bool r = false;
			for (size_t j = 0; j < v[ss.top()].size(); j++) {
				if (!visited[v[ss.top()][j]]) {
					visited[v[ss.top()][j]] = true;
					ss.push(v[ss.top()][j]);
					r = true;
					break;
				} else {
					count++;
				}
			}
			if (!r && count == v[ss.top()].size()) {
				break;
			}
		}
		if (ss.size() > 1) {
			std::cout << ss.size() << std::endl;
			while (!ss.empty()) {
				std::cout << ss.top() + 1 << std::endl;
				ss.pop();
			}
			return 0;
		}
		while (!ss.empty()) {
			ss.pop();
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int MAXN = 1e5+5;
int N, Q, K;

vector<pii> adj[MAXN];
ll len[MAXN];

void dfs(int pos, int par){
    for(pii p : adj[pos]){
        if(p.first != par){
            len[p.first] = len[pos] + p.second;
            dfs(p.first, pos);
        }
    }
}

int main(){
    cin >> N;
    for(int a = 0; a < N - 1; a++){
        int u, v, c;
        cin >> u >> v >> c;
        adj[u].push_back({v, c});
        adj[v].push_back({u, c});
    }
    cin >> Q >> K;
    dfs(K, -1);
    while(Q--){
        int u, v;
        cin >> u >> v;
        cout << len[u] + len[v] << "\n";
    }
}

Measured memory_bytes: 12800
using System;

namespace abc168_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if(s.Length <= k)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine(s.Substring(0, k) +"...");
            }
            Console.Read();
        }
        
    }
}


Measured memory_bytes: 27424
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <utility>
#include <set>
#include <unordered_map>

#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 IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<long> B(N-1);
  for(int i=0;i<N-1;i++){
    cin >> B[i];
  }
  vector<long> A(N);
  A[N-1] = B[N-2];
  for(int i = N -2; i >= 1;i--){
    A[i] = min(B[i], B[i-1]);
  }
  A[0] = B[0];
  // for(auto e:A){
  //   cout << e << endl;
  // }
  cout << accumulate(A.begin(), A.end(), 0) << endl;
  return 0;
}


Measured memory_bytes: 256
x = int(input())


if x >= 400 and x <= 599:
    print("8")
elif x >= 600 and x <= 799:
    print("7")
elif x >= 800 and x <= 999:
    print("6")
elif x >= 1000 and x <= 1199:
    print("5")
elif x >= 1200 and x <= 1399:
    print("4")
elif x >= 1400 and x <= 1599:
    print("3")
elif x >= 1600 and x <= 1799:
    print("2")
elif x >= 1800 and x <= 1999:
    print("1")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={-1,1,0,0};
int dc[]={0,0,-1,1};
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<a*b;

}


Measured memory_bytes: 3652
n=200000
mod=10**9+7
def pf(x,y,p):
  if y==0: return 1
  if y%2==0:
    d=pf(x,y//2,p)
    return d*d%p
  if y%2==1:
    return (x*pf(x,y-1,p))%p
facl=[1]
for i in range(1,n+2):
  facl.append(facl[i-1]*i%mod)
invl=[1]*(n+2)
for i in range(1,n+2):
  invl[i]=pf(facl[i],mod-2,mod)
def comb(x,k):
  if x<0 or k<0 or x<k: return 0
  if x==0 or k==0: return 1
  return (facl[x]*invl[k]*invl[x-k])%mod
h,w,a,b=map(int,input().split())
if h-a<w-b:
  h,w=w,h
  a,b=b,a
t=0
for i in range(w-b):
  t+=comb(h-a+b-1,b+i)*comb(w-b+a-1,a+i)
print(t%mod)

Measured memory_bytes: 54512
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    string ans = "NO\n";
    if(n == 3) ans = "YES\n";
    if(n == 5) ans = "YES\n";
    if(n == 7) ans = "YES\n";
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
def main():
  N = int(input())
  A = list(map(int, input().split()))

  X = A[0]

  for i in range(1, N):
    X = X ^ A[i]

  B = []

  for v in A:
    B.append(X ^ v)
  
  print(" ".join(map(str, B)))

if __name__ == "__main__":
  main()

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,m; cin>>n>>m;
  vector<vi> v(n,vi(2));
  rep(i,m){
    int a,b; cin>>a>>b;
    a--; b--;
    if(a>b) swap(a,b);
    v[a][0]++;
    v[b][1]++;
  }
  
  bool ok=true;
  rep(i,n){
    int now=v[i][0]-v[i][1];
    if(now%2!=0){
      ok=false;
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

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

int main()
{
	int a,b,t,p;
	cin >> a >> b;
	int jia,jian,cheng;
	jia = a + b;
	jian = a - b;
	cheng = a * b;
	t = max(jia,jian);
	p = max(t,cheng);
	cout << p;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans,anss;
int n,a[484844];
int main(){
	scanf("%d",&n);
	a[0]=0;
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	a[n+1]=0;
	for (int i=0;i<=n;i++)
		anss+=abs(a[i+1]-a[i]);
	for (int i=1;i<=n;i++)
	{
		ans=anss;
		ans-=abs(a[i]-a[i-1]);
		ans-=abs(a[i+1]-a[i]);
		ans+=abs(a[i+1]-a[i-1]);
		cout<<ans<<endl;
	}
}
	
	
		

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

class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String n = sc.next();
        String m = sc.next();

        System.out.println(m+""+n);
    }
}

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 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: 21076
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[9],r[9],g[9],b[9],n;
  char c;
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;j<9;j++){
      cin>>a[j];
      a[j]--;
    }
    memset(r,0,sizeof(r));
    memset(g,0,sizeof(g));
    memset(b,0,sizeof(b));
    for(j=0;j<9;j++){
      cin>>c;
      if(0){
      }else if(c=='R'){
	r[a[j]]++;
      }else if(c=='G'){
	g[a[j]]++;
      }else if(c=='B'){
	b[a[j]]++;
      }
    }
    j=0;
    for(k=0;k<9;k++){
      if(r[k]>2){
	r[k]-=3;
	j++;
      }
      if(g[k]>2){
	g[k]-=3;
	j++;
      }
      if(b[k]>2){
	b[k]-=3;
	j++;
      }
    }
    for(l=0;l<7;l++){
      for(k=0;k<2;k++){
	if(r[l]&&r[l+1]&&r[l+2]){
	  r[l]--;
	  r[l+1]--;
	  r[l+2]--;
	  j++;
	}
	if(g[l]&&g[l+1]&&g[l+2]){
	  g[l]--;
	  g[l+1]--;
	  g[l+2]--;
	  j++;
	}
	if(b[l]&&b[l+1]&&b[l+2]){
	  b[l]--;
	  b[l+1]--;
	  b[l+2]--;
	  j++;
	}
      }
    }
    cout<<(j>2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
from collections import deque
#import numpy as np
import math
#sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    exclude = set()
    prime = set()
    for i in range(2,int(math.sqrt(x))+1):
        if i in exclude:
            continue
        prime.add(i)
        j = i
        while j<=x+2*i:
            exclude.add(j)
            j += i
    current = x
    while True:
        for rep in prime:
            if current%rep==0:
                break
        else:
            print(current)
            return
        current += 1
    return

if __name__=='__main__':
    x = I()
    solve()

Measured memory_bytes: 17592
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

const int N=20;

double dis[N][N],a[N],b[N],c[N];
int num[1<<N]={0};

int main(){
    int n,m;
    for(int i=0;i<(1<<N);i++){
        for(int j=0;j<N;j++){
            if(i&(1<<j)) num[i]++;
        }
    }
    while(cin>>n>>m){
        for(int i=0;i<n;i++) scanf("%lf%lf%lf",&a[i],&b[i],&c[i]);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dis[i][j]=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]);
            }
        }
        double res=0;
        for(int i=0;i<(1<<n);i++){
            if(num[i]!=m) continue;
            double sum=0;
            for(int j=0;j<n;j++){
                if(((1<<j)&i)==0) continue;
                for(int k=j+1;k<n;k++){
                    if(((1<<k)&i)==0) continue;
                    sum+=dis[j][k];
                }
            }
            res=max(res,sum);
        }
        printf("%.10f\n",res);
    }
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> H(N);
  for (auto &i : H) cin >> i;
  
  vector<int> bools(N, 1);
  for (int i=0; i<M; i++) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    if (H[A] <= H[B]) bools[A] = 0;
    if (H[A] >= H[B]) bools[B] = 0;
  }
  cout << accumulate(bools.begin(), bools.end(), 0) << endl;
}

Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
using namespace std;
int h,n;
int a[100005];
int ans;
int main(){
	cin >> h >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
		ans += a[i];
	if(ans >= h) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }

  FOR(i,1,N-1){
    if(a[i]>a[i-1]) --a[i];
    // cout << a[i] << endl;
  }

  bool flag = true;
  FOR(i,1,N-1){
    if(a[i]<a[i-1]) flag = false;
    // cout << a[i] << " " << a[i-1] << endl;
    // cout << flag << endl;
  }

  if(flag==true) cout << "Yes" << endl;
  else cout << "No" << endl;

}



Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main(void){
  char input[110];
  int i,j;
  int miss=0;
  gets(input);
  i=0;
  j=strlen(input)-1;
  while(i!=j){
      if(input[i]!=input[j]){
          miss++;
      }
      i++;
      j--;
  }
  if(miss==0){
      i=0;
      j=((strlen(input)+3)/2)-1;
      while(i!=((strlen(input)-1)/2)){
          if(input[i]!=input[j]){
              miss++;
          }
          i++;
          j++;
      }
      
  }
  if(miss!=0){
      printf("No\n");
  }else{
      printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
    int A, B;

    scanf("%d %d", &A, &B);

    if(A>12){
        printf("%d", B);
    }else if(A>5){
        printf("%d", B/2);
    }else{
        printf("%d", 0);
    }

    return 0;
}

Measured memory_bytes: 128
import itertools
import collections



N = int(input())
count = [0]*N*100
m = int(N**0.5)
for x, y, z in itertools.combinations_with_replacement(range(1, m+1), 3):
  n = x**2+y**2+z**2+x*y+y*z+z*x
  k = len(set({x, y, z}))
  if k == 1:
    count[n] += 1
  elif k == 2:
    count[n] += 3
  else:
    count[n] += 6

for n in range(1, N+1):
  print(count[n])


Measured memory_bytes: 17540
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    set<int> s;
    int tmp;
    for(int i=0; i < n ; i++){
        cin >> tmp;
        s.insert(tmp);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {
	int n;
	cin >> n;
	map<long long,int> check;
	for(int i=0;i<n;i++){
		long long d;
		cin >> d;
		d--;
		check[d]++;
	}
	
	int m;
	cin >> m;
	for(int i=0;i<m;i++){
		long long t;
		cin >> t;
		t--;
		if(check[t]>0){
			check[t]--;
		}else{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}



Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string a;
  cin >> a;
  
  if (a == "A") cout << "T" << endl;
  else if (a == "T") cout << "A" << endl;
  else if (a == "C") cout << "G" << endl;
  else cout << "C" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>
#include <algorithm>
#include<iomanip>
#include <unordered_map> 
#include <queue>
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
 
#define MOD 1e9+7
 
 
int main() {
  int N;
  unordered_map<string, int> mp;
  
  cin >> N;
  
  for (int i=0; i < N; i++) {
    string s;
    cin >> s;
    mp[s] = 1;
  }
  
  cout << mp.size();
  
  //for float, double precision
  //cout << std::fixed << setprecision(15);
  return 0;
}



Measured memory_bytes: 17060
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct Edge
{
	int v;bool flag;
	int rev;
}E[2*N];
int head[N],nxt[2*N],cc=0;
void Init(int n)
{
	for(int i=0;i<=n;i++)head[i]=-1;
	cc=0;
}
void add(int u,int v)
{
	nxt[cc]=head[u];head[u]=cc;
	E[cc++]={v,false,cc};
	nxt[cc]=head[v];head[v]=cc;
	E[cc++]={u,false,cc-2};
}
vector<int>cnt[10];
int V[N];
bool has=false,flag=false;
int tar;
void dfs(int idx,int sum)
{
	if(V[idx]>2&&sum){
		if(idx==tar)flag=true;
		return;
	}
	for(int k=head[idx];k!=-1;k=nxt[k]){
		Edge&e=E[k];
		if(e.flag)continue;
		E[e.rev].flag=e.flag=true;
		dfs(e.v,sum+1);
	}
}
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	bool pass=true;
	Init(n);
	for(int i=0;i<m;i++){
		int u,v;scanf("%d%d",&u,&v);
		add(u,v);
		V[u]++,V[v]++;
	}for(int i=1;i<=n;i++){
		if(V[i]%2==1)pass=false;
		int u=V[i];
		if(u>6)u=6;
		cnt[u].push_back(i);
	}
	if(pass){
		if(!cnt[6].size()){
			if(cnt[4].size()<=1)pass=false;
			else {
				if(cnt[4].size()==2){
					tar=cnt[4][0];
					dfs(tar,0);
					pass=flag;
				}
			}
		}
	}if(pass)cout<<"Yes\n";
	else cout<<"No\n";
}


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

char S[100009];
int p[100009];

int main() {
    memset(p, -1, sizeof(p));

    scanf("%s",S+1);
    int N = strlen(S+1); bool fl = 0;
    if(S[1] == '0' || S[N] == '1') fl = 1;
    for(int i=1; i<N; i++) if(S[i] != S[N-i]) fl = 1;
    if(fl) {
        puts("-1");
        return 0;
    }

    int top = 3, now = 1, prv = 1;
    p[2] = 1;
    for(int i=2; i<=N/2; i++) {
        if(S[i] == '1') {
            p[now] = top++;
            for(int j=0; j < i-prv-1; j++) p[top++] = now;
            prv = i; now = p[now];
        }
    }
    for(int i=top; i<=N; i++) p[i] = now;

    for(int i=1; i<=N; i++) {
        if(p[i] != -1) printf("%d %d\n",i,p[i]);
    }
    return 0;
}


Measured memory_bytes: 1920
//*****************************believer******************************//
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef map<ll,ll> mi;
 
#define f first
#define ss second
#define ins insert
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define pq priority_queue
#define sqr(n) floor(sqrt(n))
#define sz(v) ((ll)(v.size()))
#define trav(a,x) for (auto& a: x)
#define all(v) (v).begin(),(v).end()
#define arl(v) (v).rbegin(),(v).rend()
#define mem(a) memset(a, -1, sizeof (a))
#define ssort(v) sort((v).begin(),(v).end())
#define rsort(v) sort((v).rbegin(),(v).rend())
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define vmn(a) (*min_element(a.begin(),a.end()))
#define vmx(a) (*max_element(a.begin(),a.end()))
#define foo(i,a,b) for (ll i = (a); i < (b); ++i)
#define foor(i,a,b) for (ll i = (a); i >= (b); --i)

const ll N=2e5+100;
ll wt[105],val[105];
ll n,w;
////this is the dp bw values and N which is different from the previous...
ll dp[N][105];


ll solve(ll x,ll num)
{
    ///base condition;
    if(num==0)
    return (x==0)?0:1e12;
    
    if(dp[x][num]!=-1)
    return dp[x][num];
    
    if(val[num]>x)
    return dp[x][num]=solve(x,num-1);
    
    else
    return dp[x][num]=min(solve(x,num-1),solve(x-val[num],num-1)+wt[num]);
    
}


ll solve1(ll x)
{
    foor(i,x,0)
    if(solve(i,n)<=w)
    return i;
}

int main()
{
    cin>>n>>w;
    ll maxx=0;
    foo(i,1,n+1)
    {
        cin>>wt[i]>>val[i];
        maxx+=val[i];
    }
    mem(dp);
    
    cout<<solve1(maxx)<<"\n";
    
    return 0;
}


Measured memory_bytes: 167684
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n;
           cin >> n;
           
           cout << (1000 - (n % 1000)) % 1000<< endl;
        }
    }



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

int Count( int a )
{
int i;
int iCnt;

	iCnt = 1;
	for( i = 3; i < a; i += 2 )
	{
		if( a % i == 0 ) iCnt++;
	}

	return iCnt + 1;
}

int main()
{
int i;
int N;
int iCnt;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;

	iCnt = 0;
	for( i = 105; i <= N; i += 2 )
	{
		if( Count( i ) == 8 ) iCnt++;
	}

	cout << iCnt << endl;

	return 0;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W;
  cin >> H >> W;
  ll ans = 0;
  if (H == 1 || W == 1)
    ans = 1;
  else if (H % 2 == 0 || W % 2 == 0)
  {
    ans = H * W / 2;
  }
  else
    ans = (H * W + 1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

#include <unordered_map>
#include <vector>
#include <cmath>

using prime_map = std::unordered_map<int, int>;
class Factoriser
{
    std::vector<int> factors;

public:
    Factoriser(int N)
    {
        factors.resize(N+1, 0);
        int sqrN = static_cast<int>(std::sqrt(N));

        for (int i = 2; i <= sqrN; ++i)
        {
            if (factors[i] == 0)
            {
                for (int j = i * 2; j <= N; j += i)
                {
                    if (factors[j] == 0)
                    {
                        factors[j] = i;
                    }
                }
            }
        }
    }

    prime_map Factorise(int M) const
    {
        prime_map P;
        int mm = M;

        while (factors[mm])
        {
            ++P[factors[mm]];
            mm /= factors[mm];
        }

        if (mm >= 2) ++P[mm];
        return P;
    }
    
    bool IsPrime(int M) const
    {
        return factors[M] == 0;
    }
};


void f(ll &A, ll &B, ll K)
{
    if (A >= K)
    {
        A -= K;
        return;
    }

    K -= A;
    A = 0;

    if (B >= K)
    {
        B -= K;
        return;
    }

    B = 0;
}

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

    constexpr int MAX = 1e5+100;
    Factoriser fact(MAX);

    int ans;
    for (int x = X; x < MAX; x++)
    {
        if (fact.IsPrime(x))
        {
            ans = x;
            break;
        }
    }

    cout << ans << endl;    
}


Measured memory_bytes: 640
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int count = 0;
        int count500yen = sc.nextInt();
        int count100yen = sc.nextInt();
        int count50yen = sc.nextInt();
        int answerAmount = sc.nextInt();
        
        for (int i = 0; i <= count500yen; i++) {
            for (int j = 0; j <= count100yen; j++) {
                for (int k = 0; k <= count50yen; k++) {
                    int amount = 500 * i + 100 * j + 50 * k;
                    if (amount == answerAmount) count++;
                }
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h> 
using namespace std; 
  
typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
  
#define rep(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define revrep(a, b, c) for (int(a) = (c-1); (a) >= (b); --(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 

int main() 
{ 
    string s;
    ll t,i,j;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
} 

Measured memory_bytes: 256
import sys
from collections import defaultdict
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]
    mod = [defaultdict(int), defaultdict(int), defaultdict(int)]
    for i in range(N):
        c = list(map(int, input().split()))
        for j in range(N):
            mod[(i + j) % 3][c[j] - 1] += 1
    #print(mod)
    
    hq = [[], [], []]
    for i in range(3):
        for y in range(C):
            diff = 0
            for x in mod[i]: diff += D[x][y] * mod[i][x]
            heappush(hq[i], (diff, y))
    #print(hq)
    
    cand = [[], [], []]
    for i in range(3):
        for _ in range(3):
            diff, color = heappop(hq[i])
            cand[i].append((diff, color))
    #print(cand)
    ans = 10**18
    for p in cand[0]:
        for q in cand[1]:
            for r in cand[2]:
                if p[1] == q[1] or q[1] == r[1] or r[1] == p[1]: continue
                ans = min(ans, p[0] + q[0] + r[0])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74568
n = int(input())
x = [int(e) for e in input().split()]

min_sum = 10e9
for i in range(1,100):
    sum = 0
    for j in range(0,n):
        sum += (x[j]-i)*(x[j]-i)
    if sum < min_sum:
        min_sum = sum
print(min_sum)

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

int main(){
  string s;
  cin>>s;
  int sz=s.size();
  for(int i=0;i<sz;i++){
    for(int j=i+1;j<sz;j++){
      if(s[i]==s[j]){ cout<<"no"; return 0; }
      else continue;
    }
  }
  cout<<"yes";

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#define LengthOf(x)    (sizeof(x) / sizeof(x[0]))



#if 1
//No.1
int main()
{
	INT R;
	cin >> R;

	cout << 2 * R * 3.14159265359;
	return 0;
}
#endif


Measured memory_bytes: 3792
s = input()
tmp = s
while True:
  s = s.replace("mew", "Y")
  s = s.replace("mXeXw", "Y")
  s = s.replace("meXw", "Y")
  s = s.replace("mXew", "Y")
  s = s.replace("Y", "X")
  if s == tmp:
    if s == "X" or s == "":
      print("Cat")
    else:
      print("Rabbit")
    break
  tmp = s



Measured memory_bytes: 5556
n,k=map(int,input().split())
a = list(map(int, input().split()))

b = [(abs(i), 1 if i >= 0 else -1) for i in a]

b = sorted(b)
b = list(reversed(b))
mod = int(1e9 + 7)

def fp(x,y):
	res=1
	while y > 0:
		if y % 2 == 1:
			res *= x
		x *= x
		y //= 2
		x %= mod
		res %= mod
	return res

def inv(x):
	return fp(x,mod-2)

p = 1
signe = 1
for i in range(k):
	p *= b[i][0]
	p %= mod
	if b[i][0] == 0:
		signe = 0
	signe *= b[i][1]

if signe >= 0:
	print(p % mod)
else:
	# choice between replacing the last positive by the next negative
	# and replacing the last negative by the next positive
	lastP, nextP, lastN, nextN = -1, -1, -1, -1
	for i in range(k):
		if b[i][0] * b[i][1] >= 0:
			lastP = i
		if b[i][0] * b[i][1] <= 0:
			lastN = i
	for i in range(k, n):
		if b[i][0] * b[i][1] >= 0 and nextP==-1:
			nextP = i
		if b[i][0] * b[i][1] <= 0 and nextN==-1:
			nextN = i
	if (lastP!=-1 and nextN !=-1) and (lastN!=-1 and nextP!=-1):
		if b[nextN][0] * b[lastN][0] >= b[nextP][0] * b[lastP][0]:
			ans = p * inv(b[lastP][0]) * b[nextN][0]
			ans %= mod
			print(ans)
		else:
			ans = p * inv(b[lastN][0]) * b[nextP][0]
			ans %= mod
			print(ans)
	elif lastP!=-1 and nextN!=-1:
		ans = p * inv(b[lastP][0]) * b[nextN][0]
		ans %= mod
		print(ans)
	elif lastN!=-1 and nextP!=-1:
		ans = p * inv(b[lastN][0]) * b[nextP][0]
		ans %= mod
		print(ans)
	else:
		# tout le monde est negatif
		a = list(reversed(sorted(a)))
		p = 1
		for i in range(k):
			p *= a[i]
			p %= mod
		print(p)


Measured memory_bytes: 113208
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n,x;
  cin >> n >> x;
  int l[n];
  rep(i,n)cin >> l[i];
  int cnt=1;
  int len=0;
  rep(i,n){
    len+=l[i];
    if(len<=x)cnt++;
  }
  cout << cnt << endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
  int n;cin>>n;
  vector<vector<int>> v(n-1,vector<int>(3)) ;
  rep(i,n-1)cin>>v[i][0]>>v[i][1]>>v[i][2];
  vector<int> dp(n+10,0);
  FOR(j,0,n-2){
  dp[j]=0;
  dp[j+1]=v[j][1]+v[j][0];
  FOR(i,1,n-2-j){
    int a,b;
    //a=dp[i]+(dp[i]-dp[i-1]);
    if(dp[i+j]<=v[i+j][1])b=v[i+j][1]+v[i+j][0];
    else {
      int t=v[i+j][1];
      while(true){
        t+=v[i+j][2];
        if(t>=dp[i+j])break;
      }
      b=t+v[i+j][0];
    }
    dp[i+j+1]=b;
  }
  cout<<dp[n-1]<<endl;;
  }
  cout<<0<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <limits.h>
#include <float.h>
#include <queue>
#include <cstring>

#define eps 10e-5
#define INF 1e8
#define M INT_MAX
using namespace std;

struct P{
	double x;
	double y;

	P(){
		x=M; y=M;
	}

	P(const double &s , const double &e)
		{ x=s; y=e;}

	P operator - (const P &t) const
	{ return P(x-t.x , y-t.y); }

	P operator + (const P &t) const
	{ return P(x+t.x , y+t.y); }

	P operator * (const double &d) const
	{ return P(x*d , y*d); }

};

double dis(P t);

struct L{
	P p1,p2;

	L(){}

	L(const P &s , const P &e)
		{ p1=s; p2=e;}
	double ldis(){
		return dis(p1-p2);
	}
};

struct C{
	P a;
	double r;
	C(){}
	C(const P &s , const double &e)
		{ a=s; r=e;}
};

//距離を求める
double dis(P t){
	return sqrt(t.x*t.x+t.y*t.y);
}

//単位ベクトルを求める
P unit_vector(P t){
	double u=fabs(dis(t));
	return P(t.x/u , t.y/u);
}

//外積を求める a×b
double cross(P a,P b){
	return (a.x*b.y-a.y*b.x);
}

//線分交差判定
bool intersect_s(P a1 , P a2 , P b1 , P b2){
	return ( cross(a2-a1 , b1-a1)*cross(a2-a1 , b2-a1) < eps) &&
		   ( cross(b2-b1 , a1-b1)*cross(b2-b1 , a2-b1) < eps);
}




//点pを中心としてr(radian)回転		p(0,0)で原点を中心として回転
P rotate(P t , P p , double r){
	//double r=radians(angle);
	double ta=cos(r)*(t.x-p.x)-sin(r)*(t.y-p.y)+p.x;
	double tb=sin(r)*(t.x-p.x)+cos(r)*(t.y-p.y)+p.y;
	return P(ta , tb);
}

//応用
//２円 |x-a|=raと|x-b|=rbの交点計算
L interpoint_cc(C a , C b){
	double di=fabs(dis(a.a-b.a));
	if(di > a.r+b.r || di < fabs(a.r-b.r)) return L(P(0, 0), P(0, 0));
	double t=(a.r*a.r-b.r*b.r+di*di)/(di+di);
	double rd=acos(t/a.r);

	P dv=unit_vector(b.a-a.a);
	P g1=rotate(dv , P(0,0) , rd);
	P g2=rotate(dv , P(0,0) , -rd);
	return L(a.a+g1*a.r, a.a+g2*a.r);
}

class State{
public:
	double sum;
	int t,s;
	P cur;
	State(){}
	State(double c, int a, int b, P p):sum(c),t(a),s(b),cur(p){}
	bool operator < (const State &opp)const{
		return sum > opp.sum;
	}
};


double dp[101][2];
int v[101][2];
vector <L> Lines;

bool check(L l, int s, int t){
	for(;s<t;s++) if(!intersect_s(l.p1, l.p2, Lines[s].p1, Lines[s].p2))return 0;
	return 1;
}

main(){
	int i,j,n;

	while(cin>>n, n){
		priority_queue<State> S;
		memset(v, 0, sizeof(v));
		for(i=0;i<=100;i++) dp[i][0] = dp[i][1] = INF;
		Lines.clear();
		C Prev, Now;
		cin >> Now.a.x >> Now.a.y >> Now.r;
		P Start = Now.a;
		Lines.push_back(L(Start, Start));
		for(i=1;i<n;i++){
			Prev = Now;
			cin >> Now.a.x >> Now.a.y >> Now.r;
			Lines.push_back(interpoint_cc(Now, Prev));
		}
		Lines.push_back(L(Now.a, Now.a));
		S.push(State(0, 0, 0, Start));
		while(!S.empty()){
			State t = S.top();S.pop();
			if(v[t.t][t.s]) continue;
			v[t.t][t.s] = 1;
			if(t.t == n) break;
			for(i=t.t+1;i<=n;i++){
				for(j=0;j<2;j++){
					if(v[i][j]) continue;
					L l = L(t.cur, (j?Lines[i].p2:Lines[i].p1));
					if(!check(l, t.t+1, i)) continue;
					if(dp[i][j] < l.ldis() + t.sum) continue;
					dp[i][j] = l.ldis() + t.sum;
					S.push(State(dp[i][j], i, j, l.p2));
				}
			}
		}
		printf("%.4lf\n", dp[n][0]);
	}
}

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

typedef long long int ll;
#define T int t,q; scanf("%d",&t); for(q=1;q<=t;q++)
ll ar[200];
ll sea(ll x,ll n){
	ll f=0;
	for(int i=0;i<n;i++){
		if(ar[i]==x)f=1;
	}
	return f;
}
int main(){
	ll n,i,x;
	cin >> x >> n;
	//ll ar[n+5];
	
	for(i=0;i<n;i++){
		cin >> ar[i];
	}
	ll ans1,ans2,ans;
	for(i=x;;i++){
		if(sea(i,n)==0){
			ans1=i;
			break;
		}
	}
	for(i=x-1;;i--){
		if(sea(i,n)==0){
			ans2=i;
			break;
		}
	}
	if((ans1-x)<(x-ans2))ans=ans1;
	else ans=ans2;
   cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3632
h, w = map(int, input().split())

list1 = []
moziretu = ""

for i in range(h):
    s = input()
    moziretu = list(s.replace(".", "0").replace(".", "9"))
    moziretu = [int(c) if c.isdecimal() else c for c in moziretu]
    list1.append(moziretu)
    
for i in range(h):
    for j in range(w):
        if list1[i][j] == "#":
            try:
                if i-1 >= 0 and j-1 >= 0:
                    list1[i-1][j-1] += 1
            except:
                pass
            try:
                if i-1 >= 0:
                    list1[i-1][j] += 1
            except:
                pass
            try:
                if i-1 >= 0:
                    list1[i-1][j+1] += 1
            except:
                pass
            try:
                if j-1 >= 0:
                    list1[i][j-1] += 1
            except:
                pass            
            try:
                list1[i][j+1] += 1
            except:
                pass            
            try:
                if j-1 >= 0:
                    list1[i+1][j-1] += 1
            except:
                pass            
            try:
                list1[i+1][j] += 1
            except:
                pass            
            try:
                list1[i+1][j+1] += 1
            except:
                pass
            
for i in range(h):
    for j in range(w):
        try:
            list1[i][j] = str(list1[i][j])
        except:
            pass

for i in range(h):
    print("".join(list1[i]))


Measured memory_bytes: 3188
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        int[][] table = new int[r+1][c+1];

        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++){
                table[i][j] = sc.nextInt();
                table[r][j] += table[i][j];
                table[i][c] += table[i][j];
                table[r][c] += table[i][j];
            }
        }
        for(int i=0;i<=r;i++){
            for(int j=0;j<=c;j++){
                if(j==c){System.out.print(table[i][j]);}
                else{System.out.print(table[i][j] + " ");}
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 41604
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
count = 0

while count < N do
    A.each do |a|
        if a % 2 == 0 
            if (a % 3 == 0) || ( a % 5 == 0)
                count += 1
            else count = N + 1
            end
        else count += 1

        end

    end
end

if count == N
     puts "APPROVED"
else puts "DENIED"

end

Measured memory_bytes: 1788
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int X, A, B;
    cin >> X >> A >> B;
    if (B <= A)
        cout << "delicious";
    else if (B <= A + X)
        cout << "safe";
    else
        cout << "dangerous";
    cout << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int Compute(int p,int x){
	return p*(100+x)/100;
}

void Solve(){
	int x,y,s;
	while(true){
		cin >> x >> y >> s;
		if(x==0&&y==0&&s==0) break;

		int ans=0;
		REP(i,1,s){
			REP(j,1,s){
				int a=i,b=s-j;
				if(Compute(a,x)+Compute(b,x)==s) ans=max(ans,Compute(a,y)+Compute(b,y));
			}
		}

		cout << ans << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1192
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;
 
int main()
{
	int a, b, h, m;
	scanf ("%d %d %d %d", &a, &b, &h, &m);
 
	double pi = acos(-1.0);
	double ax = a * cos(2 * pi * (h * 60 + m) / 720);
	double ay = a * sin(2 * pi * (h * 60 + m) / 720);
	double bx = b * cos(2 * pi * m / 60);
	double by = b * sin(2 * pi * m / 60);
 
	printf ("%.15lf\n", hypot(ax - bx, ay - by));
 
	return 0;
}

Measured memory_bytes: 2512