akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)

const double pi = acos(-1);
const double eps = 1e-10;
double a, b, x;
double area;

bool check_1(double d)
{
	double t = tan(d * pi / 180);
	double tmp = b * b / 2 / t;

	return x <= tmp + eps;
}

bool check_2(double d)
{
	double t = tan(d * pi / 180);
	double tmp = area - a * a / 2 * t;

	return x <= tmp + eps;
}

int main()
{
	cin >> a >> b >> x;
	x /= a;
	area = a * b;

	if (x <= a * b / 2)
	{
		double ng = 180-eps;
		double ok = 0;
		REP(i, 100)
		{
			auto mid = (ng + ok) / 2;
			if (check_1(mid))
				ok = mid;
			else
				ng = mid;
		}

		cout << setprecision(9) << ok << endl;
		return 0;
	}

	double ng = 180 - eps;
	double ok = 0;

	REP(i, 100)
	{
		auto mid = (ng + ok) / 2;
		if (check_2(mid))
			ok = mid;
		else
			ng = mid;
	}

	cout << setprecision(10) << ok << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<deque>
#define maxn 100010
#define mod 1000000007
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m;
int pos[maxn];
struct Mat{
    int a[4][4];
    void init()
    {
        memset(a,0,sizeof(a));
        a[1][1]=a[2][2]=a[3][3]=1;
    }
    void operator *= (Mat x)
    {
        int tmp[4][4];
        for(int i=1;i<=3;i++)
        {
            for(int j=1;j<=3;j++)
            {
                tmp[i][j]=0;
                for(int k=1;k<=3;k++)  tmp[i][j]=(tmp[i][j]+1ll*a[i][k]*x.a[k][j]%mod)%mod;
            }
        }
        for(int i=1;i<=3;i++)
          for(int j=1;j<=3;j++)  a[i][j]=tmp[i][j];
    }
}A,B,ans;
Mat quick_pow(Mat x,int p)
{
    Mat res;res.init();
    while(p)
    {
        if(p&1)  res*=x;
        x*=x;
        p>>=1;
    }
    return res;
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=m;i++)  pos[i]=read();
    pos[++m]=n;
    A.a[1][1]=1;A.a[1][2]=0;A.a[1][3]=0;
    A.a[2][1]=1;A.a[2][2]=1;A.a[2][3]=0;
    A.a[3][1]=1;A.a[3][2]=2;A.a[3][3]=1;

    B.a[1][1]=2;B.a[1][2]=2;B.a[1][3]=1;
    B.a[2][1]=1;B.a[2][2]=1;B.a[2][3]=0;
    B.a[3][1]=1;B.a[3][2]=2;B.a[3][3]=1;

    ans.init();
    for(int i=1;i<=m;i++)
    {
        ans*=quick_pow(B,pos[i]-pos[i-1]-1);
        if(i<m) ans*=A; 
    }
    int res=0;
    for(int i=1;i<=3;i++)  res=(res+ans.a[i][1])%mod;
    res=(res+ans.a[2][1])%mod;
    cout<<res<<endl;
    return 0;
}

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

using namespace std;


int main() {
    int n;
    cin>>n;
    long long num[n];
    long long sum=0;
    for (int i = 0; i < n; ++i) {
        cin>>num[i];
        sum+=num[i];
    }
    long long  re=1000000000000000000LL, temp;
    temp = 0;
    for (int j = 0; j < n-1; ++j) {
        temp+=num[j];
        re=min(re,abs(sum-2*temp));
    }
    cout<<re<<endl;
    return 0;
}

Measured memory_bytes: 1792
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	K, _ := strconv.Atoi(read())
	Q, _ := strconv.Atoi(read())

	A, a := make([]int, Q), make([]int, N)
	for i := 0; i < Q; i++ {
		A[i], _ = strconv.Atoi(read())
	}
	for i := 0; i < Q; i++ {
		a[A[i]-1]++
	}
	for i := 0; i < N; i++ {
		if a[i] > Q-K {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 4864
#include<string>
#include<iostream>
#include<map>
using namespace std;
int head[200001],num_edge,n,l,p,fa[200001];
struct Edge
{
	int next,to;
}edge[200001];
int v[200001],ans[200001];
void add(int from,int to)
{
	edge[++num_edge].next=head[from];
	edge[num_edge].to=to;
	head[from]=num_edge;
}
int find(int x)
{
    if(fa[x]==x) return x;
    else return fa[x]=find(fa[x]);
}
void get_together(int a,int b)
{
    fa[find(a)]=find(b);
}
void dfs1(int x,int tag,map<int,int>&num)
{
	if(v[x]==tag) return ;
	v[x]=tag;
	num[find(x)]++;
	for(int i=head[x];i;i=edge[i].next)
	  dfs1(edge[i].to,tag,num);
}
void dfs2(int x,int tag,map<int,int>&num)
{
	if(v[x]==tag) return ;
	v[x]=tag;
	ans[x]+=num[find(x)];
	for(int i=head[x];i;i=edge[i].next)
	  dfs2(edge[i].to,tag,num);
}
int main(){
	cin>>n>>p>>l;
	for(int i=1;i<=n;i++)
	  fa[i]=i;
	for(int i=1;i<=p;i++)
	{
		int a,b;
		cin>>a>>b;
		get_together(a,b);
	}
	for(int i=1;i<=l;i++)
	{
		int a,b;
		cin>>a>>b;
		add(a,b);
		add(b,a);
	}
	for(int i=1;i<=n;i++)
	  if(!v[i])
	  {
	  	map<int,int> num;
	  	dfs1(i,i,num);
	  	dfs2(i,-i,num);
	  }
	for(int i=1;i<=n;i++)
	  cout<<ans[i]<<' ';
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int k;
  cin >> k;
  string s = "ACL";
  string ans = "";
  rep(i,k){
    ans+=s;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string str;
    cin >> str;
    
    ll l = 0;
    ll r = str.size()-1;
    
    ll ans = 0;

    while((l+1) <= r){
        if(str[l] == str[r]){
            l++;
            r--;
        }
        else if(str[l]=='x'){
            l++;
            ans ++;
        }
        else if(str[r]=='x'){
            r--;
            ans ++;
        }
        else{
            cout << "-1" << endl;
            return 0;
        }
    }
    
    
    
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main(void) {
	int i, j;
	int n;
	int count;
	_Bool *p;
	
	while (scanf("%d", &n) != EOF){
		p = calloc(1, n);
		*p = 1;
		i = 2;
		count = 0;
		
		do {
			for (; *(p+i-1); i++);
			count++;
			for (j = 1; i*j <= n; j++)
				*(p+i*j-1) = 1;
		} while (i < sqrt(n) );
		for (;i <= n; i++)
			if( !( *(p+i-1) ))
				count++;
		free(p);
		
		if( n < 2)
			count = 0;
		
		printf("%d\n", count++);
	}
	
	return 0;
}

Measured memory_bytes: 1656
// {{{ by unolight
#pragma region
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion
// }}}

void main() {
    int n;
    R(n);
    VI A(n),B(n);
    VI ca(n+1),cb(n+1);
    REP(i,n) R(A[i]);
    REP(i,n) R(B[i]);
    REP(i,n) ca[A[i]]++;
    REP(i,n) cb[B[i]]++;
    REP1(i,1,n) if ( ca[i]+cb[i]>n ) { W("No"); return; }
    REP1(i,1,n) ca[i]+=ca[i-1];
    REP1(i,1,n) cb[i]+=cb[i-1];
    int x=0;
    REP1(i,1,n) chmax(x, ca[i]-cb[i-1]);
    W("Yes");
    VI ans(n);
    REP(i,n) ans[(i+x)%n]=B[i];
    W(ans);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 7332
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }
  async function solve() {
    const sc = new Scanner();
    const [A, B, K]: number[] = (await sc.getLine()).split(' ').map((x) => +x);
    const s = Math.max(A, B);
    let cnt = K;
    for (let i = s; i > 0; i -= 1) {
      if (A % i === 0 && B % i === 0) {
        cnt -= 1;
      }
      if (cnt === 0) {
        console.log(i);
        break;
      }
    }
    sc.close();
  }

  solve();
}


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
const int MAXN=1e5+7;
vector<int> edge[MAXN];
int dp[MAXN][2];
inline void dfs(int fa,int u,int col){
	if(dp[u][col]) return;
	long long ret(1);
	for(auto v : edge[u]){
		if(v==fa) continue;
		if(col){
			dfs(u,v,0),dfs(u,v,1);
			(ret*=dp[v][0]+dp[v][1])%=MOD;
		} else {
			dfs(u,v,1);
			(ret*=dp[v][1])%=MOD;
		}
	}
	
	dp[u][col]=ret;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	dfs(0,1,0),dfs(0,1,1);
	cout<<(dp[1][0]+dp[1][1])%MOD<<endl;
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#define min(a,b) ((a<b)?a:b)
#define max(a,b) ((a>b)?a:b)
#define ll long long int
#define BIG 1e9
using namespace std;

int main() {
	ll dp[101][100001]={},v[200],w[200],W,N,sum=0,ans=BIG;
	cin>>N>>W;
	for(int i=0; i<N; i++){
		cin>>w[i]>>v[i];
		sum += v[i];
	}
	for(int i=0; i<N; i++){
		for(int j=0; j<=sum; j++)dp[i][j] = BIG;
	}
	dp[0][0] = 0;
	for(int i=0; i<N; i++){
		for(int j=0; j<=sum; j++){
			if(j>=v[i]){
				dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
			}else{
				dp[i+1][j] = dp[i][j];
			}
			//cout<<i+1<<" "<<j<<" "<<dp[i+1][j]<<endl;
		}
	}
	for(int i=sum; i>=0; i--){
		if(dp[N][i]<=W){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector <int> L(N,0);
  for(int i=0;i<N;i++ )
    cin >> L[i];

  sort(L.begin(), L.end());
  int sum = 0;
  for( int i=0;i<N-1;i++ )
    sum += L[i];

  if( sum>L[N-1] )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
s = input()
 
n = len(s)
nozoku = n - 7

ans = 'NO'

if nozoku == 0:
    if s == 'keyence':
        ans = 'YES'
else:
    
    for i in range(8):
        if s[:i] + s[i+nozoku:] == 'keyence':
            ans = 'YES'
            break
   
    
print(ans) 

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int N;

    std::cin >> N;

    cout << 2.0 * M_PI * N << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 3772
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for(int i = 0; i<s.length(); i++){
            char c = s.charAt(i);
            if(c>=65 && c <= 90) System.out.printf("%c", c+32);
            else if(c>=97 && c<=122) System.out.printf("%c", c-32);
            else System.out.printf("%c", c);
        }
        System.out.printf("\n");
        sc.close();
    }
}


Measured memory_bytes: 29308
<?php

$input = intval( trim( fgets( STDIN ) ) );

$coin500 = intval($input / 500);

$input = $input - ($coin500 * 500);

$coin5 = intval($input / 5);

$input = $input - ($coin5 * 5);

echo ($coin5 * 5) + ($coin500 * 1000);

?>

Measured memory_bytes: 4728
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 3000001; //check the limits, dummy
 
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}

ll mul(ll A, ll B) {
	return (A*B)%MOD;
}

ll add(ll A, ll B) {
	return (A+B)%MOD;
}

ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}


ll* facs = new ll[MX];
ll* facInvs = new ll[MX];

ll choose(ll a, ll b) {
	if (b > a) return 0;
	if (a < 0) return 0;
	if (b < 0) return 0;
    ll cur = facs[a];
    cur = mul(cur, facInvs[b]);
    cur = mul(cur, facInvs[a-b]);
    return cur;
}

void initFacs() {
	facs[0] = 1;
	facInvs[0] = 1;
	FOR(i, 1, MX) {
		facs[i] = (facs[i-1] * i) % MOD;
		facInvs[i] = inv(facs[i]);
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    initFacs();
    ll R1, R2, C1, C2; cin >> R1 >> C1 >> R2 >> C2;
    ll ans = 0; R1--;
    FOR(i, C1, C2+1) {
        ans += choose(i+R2+1, R2);
        ans += MOD - choose(i+R1+1, R1); ans %= MOD;
    }
    cout << ans << endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 47104
#include <iostream>
#include <string>

#define MAXN 200
typedef long long ll;

using namespace std;

int main()
{
  int N;
  ll tmp;
  int ans = 0;

  cin >> N;

  cin >> tmp;
  while ( tmp % 2 == 0 ) {
    ++ans;
    tmp /= 2;
  }
  --N;

  while(N--)
  {
    scanf("%ld", &tmp);
    int cnt = 0;
    while ( tmp % 2 == 0 ) {
      ++cnt;
      tmp /= 2;
    }

    if ( ans > cnt ) ans = cnt;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
x_list=list(map(int,input().split()))
countp=0
countz=0
countn=0
for i in x_list:
    if i>0:
        countp=countp+1
    elif i==0:
        countz=countz+1
    else:
        countn=countn+1
if countz==0:
    if countp>=countn:
        if countn+k-1<=n-1:
            Min=x_list[countn+k-1]
        else:
            Min=10**16
        for i in range(countn):
            if countn+k-1-i-1<=n-1:
                m=min(x_list[countn+k-1-i-1]-2*x_list[countn-i-1],2*x_list[countn+k-1-i-1]-x_list[countn-i-1])
                Min=min(Min,m)
    else:
        if countn-1-k+1>=0:
            Min=-x_list[countn-1-k+1]
        else:
            Min=10**16
        for i in range(countp):
            if countn+i-k+1>=0:
                m=min(x_list[countn+i]-2*x_list[countn+i-k+1],2*x_list[countn+i]-x_list[countn+i-k+1])
                Min=min(Min,m)
else:
    if countp>=countn:
        if countn+k-1<=n-1:
            Min=x_list[countn+k-1]
        else:
            Min=10**16
        for i in range(countn):
            if countn+k-1-i-1<=n-1:
                m=min(x_list[countn+k-1-i-1]-2*x_list[countn-i-1],2*x_list[countn+k-1-i-1]-x_list[countn-i-1])
                Min=min(Min,m)
    else:
        if countn-k>=0:
            Min=-x_list[countn-k+1]
        else:
            Min=10**16
        for i in range(countp):
            if countn+i-k+1>=0:
                m=min(x_list[countn+i]-2*x_list[countn+i-k+1],2*x_list[countn+i]-x_list[countn+i-k+1])
                Min=min(Min,m)
print(Min)
            


Measured memory_bytes: 62832
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007



void solver()
{
	ll n,a,b;
	cin>>n>>a>>b;
	
	ll t1= n/(a+b);
	ll t2= n%(a+b);
	ll t4= min(a,t2);
	cout<< t1*a +t4;
}

signed main() 
{
	speed	
		
	ll q=1;	
	//cin>>q;	
	
	while(q--)	
	solver();	
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;
using Graph = vector<vector <bool>>;

int main(){
    int h, w, ans, cnt_ob=0;
    cin >> h >> w;
    Graph G(h, vector<bool>(w, false));
    for(int i=0; i<h; i++){
        string str;
        cin >> str;
        for(int j=0; j<w; j++){
            if(str[j] == '.'){
                G[i][j] = true;
                cnt_ob++;
            }
        }
    }

    int dx[4] = {0, 0, -1, 1};
    int dy[4] = {-1, 1, 0, 0};
    pair<int, int> p;
    vector<vector <int>> dist(h, vector<int>(w, -1));
    queue<pair<int, int>> que;
    dist[0][0] = 0;
    que.push(pair<int, int>(0,0));
    while(!que.empty()){
        p = que.front();
        que.pop();
        for(int i=0; i<4; i++){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(!G[ny][nx]) continue;
            if(dist[ny][nx] != -1) continue;
            dist[ny][nx] = dist[p.first][p.second] + 1;
            que.push(pair<int, int>(ny, nx));
        }
    }
    if(dist[h-1][w-1] == -1) ans = -1;
    else ans = cnt_ob - (dist[h-1][w-1]+1);
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

class Graph():

    def __init__(self):
        self.adjacency_dict = {}
    
    def add_vertex(self, v):
        self.adjacency_dict[v] = []

    def add_edge(self, v1, v2):
        self.adjacency_dict[v1].append(v2)
        self.adjacency_dict[v2].append(v1)

    def remove_edge(self, v1, v2):
        self.adjacency_dict[v1].remove(v2)
        self.adjacency_dict[v2].remove(v1)

    def remove_vertex(self,v):
        while self.adjacency_dict[v] != []:
            adjacency_vertex = self.adjacency_dict[v][-1]
            self.remove_edge(v, adjacency_vertex)
        del adjacency_vertex[v]

    def get_vertexes(self):
        return self.adjacency_dict.keys()

    def get_edges(self, v):
        return self.adjacency_dict[v]

    def print_graph(self):
        print(self.adjacency_dict)

import itertools

g = Graph()
N, M = map(int, input().strip().split())
for i in range(N):
    g.add_vertex(i+1)
for _ in range(M):
    a, b = map(int, input().strip().split())
    g.add_edge(a, b)
res = 0
permutations_vertexes = itertools.permutations(g.get_vertexes())
for permutation in permutations_vertexes:
    prev_vertex = permutation[0]
    if prev_vertex != 1:
        continue
    can_all_vertex = True
    for vertex in permutation:
        if prev_vertex == vertex:
            continue
        if vertex not in g.get_edges(prev_vertex):
            can_all_vertex = False
            break
        prev_vertex = vertex
    if can_all_vertex:
        res += 1
print(res)


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

int main()
{


    int64_t k,a,b;
    cin>>k>>a>>b;


    if(a+2>b||k<(a-1)+2)
        cout<<k+1<<endl;
    else{
        int64_t wk1=b+(k-(a-1)-2)/2*(b-a)+(k-(a-1)-2)%2;
        //int64_t wk2=(k-(-1)-2)/a*b+(k-(-1)-2)%a;
        cout<<max(wk1,wk1)<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n-1):
    if b==1:
        if a[i+1]<a[i]:
            b=0
            c+=1
    elif b==-1:
        if a[i+1]>a[i]:
            b=0
            c+=1
    else:
        if a[i+1]>a[i]:
            b=1
        if a[i+1]<a[i]:
            b=-1
print(c+1)

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

int main()
{
 
    // input data
    long x,y;
    cin>>x>>y;

    // count the numbr of sequences

    long wk=x;
    long cnt;
    while(wk<=y){
        wk*=2;
        cnt++;
    }

    // output data
    cout<<cnt<<endl;
    

 

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a, b = [list(map(int, input().split())) for _ in range(2)]
bSum = 0
for i in range(n):
    if a[i] >= b[i]:
        bSum += b[i]
        a[i] -= b[i]
        b[i] = 0
    elif a[i] + a[i + 1] >= b[i]:
        bSum += b[i]
        a[i + 1] -= b[i] - a[i]
        a[i] = 0
    elif a[i] + a[i + 1] <= b[i]:
        bSum += a[i] + a[i + 1]
        a[i + 1] = 0

print(bSum)


Measured memory_bytes: 18624
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int N,M,A,B,C,T;
V mul(const V &a, const V &b){
	V c(N*N);
	int i=0,j;
	for(;i<N;i++)for(j=0;j<N;j++)c[i*N+j]=(a[slice(i*N,N,1)]*b[slice(j,N,N)]).sum()%M;
	return c;
}
V exp(const V &a, const int n){
	if(n==1)return a;
	if(n&1)return mul(exp(a,n-1),a);
	V b=exp(a,n>>1);
	return mul(b,b);
}
V z(){
	V x(N*N);
	int i;
	if(T){
		x[0]=B;
		x[1]=C;
		for(i=1;i<N-1;i++){
			x[i*N+i-1]=A;
			x[i*N+i]=B;
			x[i*N+i+1]=C;
		}
		x[i*N+i-1]=A;
		x[i*N+i]=B;
		return exp(x,T);
	}else{
		for(i=0;i<N;i++)x[i*N+i]=1;
		return x;
	}
}
main(){
	int i;
	V s;
	for(;scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T),N;){
		s.resize(N);
		for(i=0;i<N;i++)scanf("%d",&s[i]);
		const V r=z();
		for(i=0;i<N;i++)printf(i<N-1?"%d ":"%d\n",(r[slice(i*N,N,1)]*s).sum()%M);
	}
}

Measured memory_bytes: 1080
#include<stdio.h>

int main() {
   
   long  n,i;
   long  N;
   long  sum=0,max=-1000001,min=1000001;

   scanf("%ld",&n);
   
   for (i=0; i<n; i++) {
      scanf("%ld",&N);
      if (max<N) {
         max=N;
      }
      if (min>N)  {
         min=N;
      }
      sum=sum+N;
   }
   
   printf("%ld %ld %ld\n",min,max,sum);
   
   return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);
    bool f = false;
    REP(a,N){
        CIN(b);
        if(b%2)f = true;
    }
    if(f){
        cout<<"first"<<endl;
    }else{
        cout<<"second"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int n;
	static int k;
	static int[] w;
	static long P;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		w = new int[n];
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
		}
		sc.close();

		P = 100000L * 100000L;

		long left = 0L;
		long right = P;

		while (left < right) {
			long mid = (left + right) / 2;
			if (allocate(mid)) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}
		System.out.println(left);

	}

	private static boolean allocate(long maxCapacity) {
		int index = 0;
		for (int i = 0; i < k; i++) {
			long cap = maxCapacity;
			while (index <= n - 1 && cap - w[index] >= 0) {
				cap -= w[index];
				index++;
			}
		}
		if (index != n) {
			return false;
		} else {
			return true;
		}
	}
}

Measured memory_bytes: 70620
package main

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

func main() {
	S := nextString()
	if S == "Sunny" {
		fmt.Println("Cloudy")
	} else if S == "Cloudy" {
		fmt.Println("Rainy")
	} else if S == "Rainy" {
		fmt.Println("Sunny")
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
using System;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] x = new int[N];
        int[] y = new int[N];
        for(int i = 0; i < N; i++)
        {
            string[] input = Console.ReadLine().Split();
            x[i] = int.Parse(input[0]);
            y[i] = int.Parse(input[1]);
        }
        double ans = 0;
        double count = 0;
        for(int i = 0; i < N - 1; i++)
        {
            for(int j =i+1; j < N; j++)
            {
                ans += Math.Sqrt(Math.Pow(x[i] - x[j], 2) + Math.Pow(y[i] - y[j], 2));
                count++;
            }
        }
        Console.WriteLine(ans * (N-1)/ count);
    }
    
}

Measured memory_bytes: 11092
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define mod(x) ((x % MOD) + MOD) % MOD
#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int,int> P;

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

signed main()
{
  int N, K;
  cin >> N >> K;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }

  vector<int> x_l, x_r;
  for (int i = 0; i < N; i++) {
    if (X[i] > 0) {
      x_r.push_back(X[i]);
    } else if (X[i] < 0) {
      x_l.push_back(X[i]);
    } else {
      K--;
    }
  }

  sort(x_l.begin(), x_l.end(), greater<int>());
  int x_l_size = (int)(x_l.size());
  int x_r_size = (int)(x_r.size());


  int ans = INF;
  if (K == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (x_r_size-1 >= K-1) {
    ans = min(ans, x_r[K-1]);
  }
  if (x_l_size-1 >= K-1) {
    ans = min(ans, -x_l[K-1]);
  }
  for (int i = 0; i < x_r_size; i++) {
    if (K-i-2 >= 0 && K-i-2 <= x_l_size-1) {
      ans = min(ans, x_r[i]*2 - x_l[K-i-2]);
    }
  }
  for (int i = 0; i < x_l_size; i++) {
    if (K-i-2 >= 0 && K-i-2 <= x_r_size-1) {
      ans = min(ans, -x_l[i]*2 + x_r[K-i-2]);
    }
  }

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


Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

long double a[3000];
long double dp[1500][3000];

long double probOfHeads(int countOfT,int n)
{
  if(n==0)
  return 1.0;
  if(dp[countOfT][n]!=-1.0)
  return dp[countOfT][n];
  long double ans=0.0;
  ans+= probOfHeads(countOfT,n-1)*a[n-1];
  if(countOfT>0)
  ans+= probOfHeads(countOfT-1,n-1)*(1.0-a[n-1]);
  return dp[countOfT][n]=ans;
}

long double bottom_up(int countOfT,int n)
{
  int i,j;
  for(i=0;i<=countOfT;i++)
  {
    for(j=0;j<=n;j++)
    {
      if(j==0)
      dp[i][j]=1.0;
      else if(i==0)
      dp[i][j]+=(dp[i][j-1]*a[j-1]);
      else
      dp[i][j]+=(dp[i][j-1]*a[j-1])+(dp[i-1][j-1]*(1.0-a[j-1]));
    }
  }
  return dp[countOfT][n];
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i,j;
    cin>>n;
    for(i=0;i<n;i++)
    cin>>a[i];
    int countOfT;
    if(n%2==0)
    countOfT=n/2-1;
    else
    countOfT=n/2;
    for(i=0;i<=countOfT;i++)
      for(j=0;j<=n;j++)
        dp[i][j]=0.0;
    
    cout<<fixed<<std::setprecision(10);

    // bottom_up
    cout<<bottom_up(countOfT,n);

    // top-down
    // cout<<probOfHeads(countOfT,n);
    return 0;
}

Measured memory_bytes: 74124
X, Y, Z, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A.sort(reverse=True)

D = [i+j for j in C for i in B]
D.sort(reverse=True)
E = [i+j for j in D[:K] for i in A[:K]]
E.sort(reverse=True)

print(*E[:K], sep="\n")

Measured memory_bytes: 146452
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
vector<int>g[N];
int dp[N][3];
int n,m,s,t;
int main(){
	//freopen("in.txt","r",stdin);
	me(dp,-1);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int u,v;
		sc("%d%d",&u,&v);
		g[u].push_back(v);
	}
	cin>>s>>t;
	queue<pair<int,int> >q;
	q.push({s,0});
	dp[s][0]=0;
	while(!q.empty()){
		int u=q.front().first;
		int x=q.front().second;
		q.pop();
		for(auto v:g[u]){
			int e=(x+1)%3;
			if(dp[v][e]>=0)continue;
			dp[v][e]=dp[u][x]+1;
			q.push({v,e});
		}
	}
	if(dp[t][0]>=0)dp[t][0]/=3;
	o(dp[t][0]);
}

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

using namespace std;

#define LL long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    int k;
    cin>>k>>s;
    if(s.size() <= k)
        cout<<s;
    else {
        for(int i=0; i<k; i++)
            cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3644
package main

import (
	"fmt"
	"sort"
)

func main() {
	x := make([]int, 3)
	fmt.Scan(&x[0])
	fmt.Scan(&x[1])
	fmt.Scan(&x[2])

	sort.Ints(x)

	fmt.Printf("%d\n", x[0]+x[1])
}


Measured memory_bytes: 512
function main(input) {
  
  var input = input;
  var sum = 0;
  for (var i=0;i<4;i++){
    if(input[i] == '+') {
    	sum += 1;
    } else {
    	sum -= 1;
    }
  }
  console.log(sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
for i in range(3000):
    x,y=map(int,input().split())
    
    if x>y:
        print(y,end=' ')
        print(x)
        
    elif y>x:
        print(x,end=' ')
        print(y)
        
        
    elif x==0 and y==0:
        break
    
    else:
        print(x,end=' ')
        print(y)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef pair<int64_t, int64_t> P;

template <typename T>
struct BIT
{
  int n;
  vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x = 1)
  {
    for (i++; i <= n; i += i & -i)
    {
      d[i] += x;
    }
  }
  T sum(int i)
  {
    T x = 0;
    for (i++; i; i -= i & -i)
    {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r)
  {
    return sum(r - 1) - sum(l - 1);
  }
};

int main()
{
  int64_t N, Q;
  cin >> N >> Q;
  vector<int64_t> A(N), pi(N + 1, -1);
  vector<vector<int64_t>> ps(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++)
  {
    int64_t l = pi[A[i]];
    if (l != -1)
      ps[l].emplace_back(i);
    pi[A[i]] = i;
  }
  vector<vector<P>> qs(N);
  for (int i = 0; i < Q; i++)
  {
    int l, r;
    cin >> l >> r;
    l--, r--;
    qs[l].emplace_back(r, i);
  }

  vector<int64_t> ans(Q);
  BIT<int64_t> d(N);
  for (int x = N - 1; x >= 0; x--)
  {
    for (int y : ps[x])
    {
      d.add(y, 1);
    }
    for (P query : qs[x])
    {
      int r = query.first, i = query.second;
      ans[i] = (r - x + 1) - d.sum(r);
    }
  }
  for (int i = 0; i < Q; i++)
  {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 70824
S = input()

# 全部一緒はダメ
if S[0] == S[1] and S[1] == S[2] and S[2] == S[3]: print('No')
elif S[0] == S[1] and S[2] == S[3]: print('Yes')
elif S[0] == S[2] and S[1] == S[3]: print('Yes')
elif S[0] == S[3] and S[1] == S[2]: print('Yes')
else: print('No')

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (l,r) = readLine()!!.split(" ").map { it.toLong() }
    if (r - l >= 2018) return println(0)
    var mod = 2018
    for (i in l until r) {
        for (j in l+1..r) {
            if (mod > i * j % 2019) mod = i.times(j).mod(2019).toInt()
            if (mod == 0) return println(0)
        }
    }
    println(mod)
}

Measured memory_bytes: 36132
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c,n,i,j,k,f;
    cin>>n;
    c=0;
    f=0;
    while(n--)
    {
        cin>>a;

        if(a%2==0)
        {
            f++;
            if(a%3==0||a%5==0)
            {
                c++;
            }
        }
    }
    if(f==c)
    {
        cout<<"APPROVED\n";
    }
    else
        cout<<"DENIED\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c1 =0 ,c2=0;
  string s;
    
  cin >> s;
  sort(s.begin(),s.end());
  if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2) && s.at(0) != s.at(3)){  cout << "Yes" << endl;  }else {cout << "No" << endl;}
   return 0;
 
}


Measured memory_bytes: 256
f[168],z[]={24,23,25,12,36,11,13,35,37,22,26,48,0},x,s;main(y){for(;s?++f[y*12+x+z[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:0;);for(x=y=0,s=23;++s<144;s%12<10?y=fmax(y,f[s]),f[s]&&++x:0);return!printf("%d\n%d\n",100-x,y);}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,k;
ll comb[2521][2521];
ll cb(ll a, ll b){
    if(b<0 || b>a || a<0)return 0;
    return comb[a][b];
}

int main(){
    scanf("%d%d",&n,&k);
    REP(i,2521)REP(j,2521){
        if(i==j || j==0)comb[i][j]=1;
        else if(j>i)comb[i][j]=0;
        else comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD;
    }
    FOR(i,1,k+1){
        ll ans = cb(n-k-(i-1)+i,i) * cb(k-i+(i-1),i-1) % MOD;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 49920
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int a;
  int b;
  int max;
  int add;
  int sub;
  int mul;

  scanf("%d%d",&a,&b);

  if(-1001>a || a>1001 || -1001>b || b>1001){ 
     exit(1);
  }


  add = a+b;
  sub = a-b;
  mul = a*b;

  max = add;
  if(max < sub ){
    max = sub;
  }
  if(max < mul ){
    max = mul;
  }

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

Measured memory_bytes: 128
#include <stdio.h>

int selection(int a[], int l,int r){
    int i, j;
    int count = 0;
    for(i = l;i < r; i++){
        int min = i;
        for(j = i+1; j<=r; j++){
            if(a[j]<a[min]) min = j;
        }
        if(min != i){
            int temp = a[min];
            a[min] = a[i];
            a[i]= temp;
            count ++;
        }
    }
    return count;
}

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

    int count = selection(A, 0, N-1);
    for (i = 0; i < N ;i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", count);

    return 0;
}

Measured memory_bytes: 1848
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def search(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
		search(values,hp+dh,vp+dv,item)
#	search(values,hp-1,vp,item)
#	search(values,hp+1,vp,item)
#	search(values,hp,vp-1,item)
#	search(values,hp,vp+1,item)

def solve(values):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in valid_items:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line = input().strip()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		values = list()
		for _ in range(H):
			values.append(list(input().strip()))
		print(solve(values))
		line = input().strip()

if __name__=='__main__':
	main()

Measured memory_bytes: 21124
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int mod=1000000007;
char g[1000][1000];
long long  a[1001][1001];
int main(){
	int h,w;
  	scanf("%d%d",&h,&w);
  	for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
        	cin>>g[i][j];
        }
    }
    a[h-1][w-1]=1;
  	for(int i=h-1;i>=0;i--){
    	for(int j=w-1;j>=0;j--){
        	if(g[i][j]=='.') a[i][j]+=a[i+1][j]+a[i][j+1];
        	a[i][j]=a[i][j]%mod;
        }
    }/*
  	for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
        	cout<<a[i][j]<<" ";
        }
      cout<<endl;
    }*/
  	cout<<a[0][0];
  	
}

Measured memory_bytes: 9088