akhauriyash/Code-Regression huggingface dataset:
import java.awt.geom.Point2D;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Map.*;



class Main {

	public static void main(String[] args) {	
		//FastScanner sc = new FastScanner();
		Scanner sc = new Scanner(System.in);
		int[] l = new int[3];
		for(int i = 0; i < 3; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		if(l[0] == 5 && l[1] == 5 && l[2] == 7) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}

	
	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        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() {
	        if (!hasNext()) throw new NoSuchElementException();
	        int 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();
	        }
	    }
	}
}



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

using namespace std;
using ll = long long;
#define mod 1000000007
ll mypower(ll a, ll b, ll p)
{
    ll ans = 1;
    a = a%p;
    while(b)
    {
        if(b%2)
            ans = ans*a % p;
        b=b/2;
        a = a*a % p;
    }
    return ans;
}
int main() {
    int n, k;
    cin >> n >> k;
    int cnt[n+1] = {0};
    int i;
    for(i=1;i<=k;i++)
    {
        int x;
        cin >> x;
        int j;
        for(j=1;j<=x;j++)
        {
            int y;
            cin >> y;
            cnt[y]++;
        }
    }
    int ans = 0;
    for(i=1;i<=n;i++)
        if(cnt[i] == 0)
            ans++;
    cout << ans << '\n';        
}

Measured memory_bytes: 3636
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) const {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int N;
vector<Int> P, Q, A;

void input() {
  cin >> N;
  Int x;
  rep(N) {
    cin >> x;
    P.push_back(x);
  }
  rep(N) {
    cin >> x;
    Q.push_back(x);
  }
}

void solve() {
  loop(i,1,N+1) {
    A.push_back(i);
  }

  Int p = 0, q = 0, nban = 0;
  do {
    if (A == P) p = nban;
    if (A == Q) q = nban;
    nban++;
  } while (next_permutation(span_all(A)));

  cout << abs(p - q) << endl;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

def b_search(A,key):
    left,right,diff = 0,len(A),0
    output = False
    count = 0
    while left < right and count < 15:
        mid = (left+right)//2
        if A[mid] == key:
            return True
        elif A[mid] < key:
            left = mid
        else:
            right = mid
        count += 1
        #print(left,mid,right)

R,G,B = [],[],[]

for i in range(N):
    if S[i] == "R":
        R.append(i+1)
    if S[i] == "G":
        G.append(i+1)
    if S[i] == "B":
        B.append(i+1)

if len(R) <= len(G) and len(B) <= len(G):
    G,B = B,G
elif len(G) <= len(R) and len(B) <= len(R):
    R,B = B,R

#最長はB
ans = 0
for i in range(len(R)):
    for j in range(len(G)):
        tmp = 0
        if R[i] < G[j]:
            #b < r < g or r < b < g or r < g < b
            if b_search(B,R[i]-(G[j]-R[i])):
                tmp += 1
            if (G[j]-R[i]) % 2 == 0 and b_search(B,(G[j]+R[i])//2):
                tmp += 1
            if b_search(B,G[j]+(G[j]-R[i])):
                tmp += 1
            ans += len(B)-tmp
        else:
            #b < g < r or g < b < r or g < r < b
            if b_search(B,G[j]-(R[i]-G[j])):
                tmp += 1
            if (R[i]-G[j]) % 2 == 0 and b_search(B,(R[i]+G[j])//2):
                tmp += 1
            if b_search(B,R[i]+(R[i]-G[j])):
                tmp += 1
            ans += len(B)-tmp

print(ans)


Measured memory_bytes: 75912
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    string s;
    cin>>n>>k>>s;
    int cnt=0;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1])cnt++;
    }
    cout<<min(cnt+2*k,n-1)<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

vector<pi> ar;
ll dp[1001][10001];

ll func(ll idx,ll k)
{
    if(idx<0){
        if(k<=0){return 0;}
        else{return INT_MAX;}
    }
    if(k<=0){return 0;}
    if(dp[idx][k]==-1){
        dp[idx][k]=min(func(idx-1,k),ar[idx].second+func(idx,k-ar[idx].first));
    }
    return dp[idx][k];
}

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

    ll h,n;
    cin>>h>>n;
    ar.resize(n);
    for(ll i=0;i<n;++i){
        cin>>ar[i].first>>ar[i].second;
    }

    memset(dp,-1,sizeof(dp));
    ll ans=func(n-1,h);
    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 78976
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	if (w % 2 == 0 && w / 2 == x && h % 2 == 0 && h / 2 == y) {
		cout << fixed << setprecision(10) << w * h / 2.0 << ' ' << 1 << endl;
	}
	else {
		cout << fixed << setprecision(10) << w * h / 2.0 << ' ' << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    double sum = 0;
    for(int i = 0;i<a;i++){
        double b;
        cin >> b;
        sum += 1/b;
    }
    cout << 1/sum << endl;
} 

Measured memory_bytes: 256
include Math

n = gets.to_i

n.times do
	x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)

	c = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
	a = ((x3 - x2) ** 2 + (y3 - y2) ** 2) ** 0.5
	b = ((x1 - x3) ** 2 + (y1 - y3) ** 2) ** 0.5

	cosA = (-a ** 2 + b **2 + c ** 2) / (2 * b * c)
	cosB = (a ** 2 - b **2 + c ** 2) / (2 * a * c)
	cosC = (a ** 2 + b **2 - c ** 2) / (2 * a * b)

	sin2A = sin(2 * acos(cosA))
	sin2B = sin(2 * acos(cosB))
	sin2C = sin(2 * acos(cosC))

	px = (x1 * sin2A + x2 * sin2B + x3 * sin2C) / (sin2A + sin2B + sin2C)
	py = (y1 * sin2A + y2 * sin2B + y3 * sin2C) / (sin2A + sin2B + sin2C)
	r = ((px - x1) ** 2 + (py - y1) ** 2) ** 0.5

	puts "%.3f %.3f %.3f" % [px, py, r]
end

Measured memory_bytes: 6300
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll n,x; cin>>n>>x;
	VL a(n), b(n); ll ans=0LL;
	rep(i,n){
		cin>>a[i]; b[i]=a[i];
		ans += a[i];
	}
	reps(i,n){
		ll cost = i*x;
		rep(j,n){
			chmin(b[j], a[(j-i+n)%n]);
			cost += b[j];
		}
		// cerr<<cost<< ' ';
		chmin(ans,cost);
	}
	// cerr<<endl;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();
    let mut t: String = read();

    for i in 0..s.len() {
        if s == t {
            println!("Yes");
            return;
        }
        let t_last = t.pop().unwrap();
        t.insert(0, t_last);
    }
    println!("No");
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
// main の while 文を x<=n に．

#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define MOD 998244353
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;
// print_item
template<typename T>
void print_item(T x) {cout << x;}
void print(auto& vec,string str="");

int solve_s(int a,int b,li k,li& x,li& y){
  x=y=k/(a+b);
  k=k-(a+b)*x;
  li xx[2]{1,0},yy[2]{0,1},s[2]{a,b};
  if(df) printf("%ld %ld %ld ",xx[0],yy[0],s[0]);
  if(df) printf("q:%ld %ld %ld rem:%d\n",x,x,y,k);
  while(s[1]){
    li q=s[0]/s[1], temp;
    temp=xx[0]-xx[1]*q;
    xx[0]=xx[1]; xx[1]=temp;
    temp=yy[0]-yy[1]*q;
    yy[0]=yy[1]; yy[1]=temp;
    temp=s[0]-s[1]*q;
    s[0]=s[1]; s[1]=temp;
    q=k/s[0];
    x+=q*xx[0];
    y+=q*yy[0];
    k-=q*s[0];
    if(df) printf("%ld %ld %ld ",xx[0],yy[0],s[0]);
    if(df)printf("q:%ld %ld %ld rem:%d\n",q,q*xx[0],q*yy[0],k);
  }
  if(k){
    if(df) printf("rem:%d",k);
    return 0;
  }
  return s[0];
}

li binom(int n,li r){
  static vector<li> fact(n+1,0),fi(n+1,0),inv(n+1,0);
  if(r<0 or r>n) return 0;
  if(fact.at(0)==0){
    fact.at(0)=fi.at(0)=1;
    fact.at(1)=fi.at(1)=inv.at(1)=1;
    repa(i,2,n+1){
      fact.at(i)=fact.at(i-1)*i%MOD;
      inv.at(i)=(MOD-(MOD/i))*inv.at(MOD%i)%MOD;
      fi.at(i)=fi.at(i-1)*inv.at(i)%MOD;
    }
    // if(df){
    //   print(fact,"fct");
    //   print(fi,"f-1");
    //   print(inv,"inv");
    // }
  }
  li s=fact.at(n);
  (s*=fi.at(r))%=MOD;
  (s*=fi.at(n-r))%=MOD;
  return s;
}

li calc(li x, li y, int n){
  return binom(n,x)*binom(n,y)%MOD;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n,a,b; li k; cin >>n >>a >>b >>k;
  li x,y;
  int d=solve_s(a,b,k,x,y);
  if(df)printf("gcd(%d,%d)=%d; %lda%+ldb=%ld\n",a,b,d,x,y,k);
  if(k>(li)(a+b)*n){
    printf("0");
    return 0;
  }
  //  return 0;
  if(d==0){
    printf("0");
    return 0;
  }
  a/=d; b/=d;
  if(x>0){
    li q=x/b;
    x-=b*q;
    y+=a*q;
  }else{
    li q=(-x+b-1)/b;
    x+=b*q;
    y-=a*q;
  }
  if(df)printf("%lda%+ldb=%ld\n",x,y,k);
  li ans=0;
  if(df)printf("(%ld,%ld)",x,y);
  while(x<=n and y>=0){
    li c=calc(x,y,n);
    if(df)printf("->%ld\n",c);
    (ans+=c)%=MOD;
    x+=b;
    y-=a;
    if(df)printf("(%ld,%ld)",x,y);
  }
  cout << ans;
}

void print(auto& vec,string str){
  if(str!="") cout << str << ":";
  for(auto x: vec) {print_item(x); cout << " ";}
  cout << endl;
}

/// confirm df==0 ///


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int K, X;
    cin >> K >> X;
    for (int i = X - K + 1; i < X + K; i++) {
        cout << i << " ";
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define bi_s binary_search
#define lb lower_bound
#define ub upper_bound
#define ll long long
using namespace std;

int n;
int k;
int x[100005];
ll ans=400000005;

int main(){
	cin >>n >>k;
  	rep(i,n){
    	cin >>x[i];
   	}

  	rep(i,n-k+1){
  		ll tmp=min(abs(x[i]-0)+x[i+k-1]-x[i],abs(x[i+k-1]-0)+x[i+k-1]-x[i]);
     	ans=min(ans,tmp);
    }
  
  	cout <<ans <<endl;
  	return 0;

}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            printf("%d\n",a+b);
        }
        if(op=='-'){
            printf("%d\n",a-b);
        }
        if(op=='*'){
            printf("%d\n",a*b);
        }
        if(op=='/'){
            printf("%d\n",a/b);
        }
        if(op=='?'){
        break;
        }
    }
}

Measured memory_bytes: 1860
def x():
    m=-10**9
    for i in N:
        p=[0]*n
        for j in range(i,n):
            for k in N:
                p[k]+=l[k][j]
            m=max(P(p),m)
    return m

def P(a):
    m,c=-10**5,0
    for x in N:
        c+=a[x]
        m=max(c,m)
        if c<0:
            c=0
    return m


n=int(raw_input())
N=range(n)
l=[]
for i in N:
    l.append(map(int,raw_input().split()))
print x()

Measured memory_bytes: 6660
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int oriN = N;

        int count = 0;
        while(N > 0) {
            N/=10;
            count++;
        }
        
       int t = count%2 == 1 ? count-2: count-1;
        
        int n1 = 0;
        for(int i = 1; i<= t; i+=2) {
            n1 += Math.pow(10, i) - Math.pow(10, i)/10;
        }

        int n2 = 0;
        if(count%2 == 1) {
            n2 = oriN - (int)Math.pow(10, count-1) +1;
        }

        System.out.println(n1+n2);
        
    }
}

Measured memory_bytes: 23380
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

dict_order = permutations(range(1, N + 1))

for n, i in enumerate(dict_order):
    if P == i:
        a = n
    if Q == i:
        b = n

print(abs(a - b))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	int  a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << "No" << endl;
		return 0;
	}
	if (a == b || a == c || b == c) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,ans1=0,ans2=0;
	scanf("%d %d",&a,&b);
	for(int i=1;i<=a-1;i++)
		ans1+=i;
	for(int j=1;j<=b-1;j++)
		ans2+=j;
	printf("%d\n",ans1+ans2);
	return 0;
}

Measured memory_bytes: 256
H,W,K=map(int,input().split())
S=[input() for i in range(H)]
P=[[0 for i in range(W)] for m in range(H)]

for h in range(H):
    if "#" in S[h]:
        front=h
        break


m=0
x=0
for w in range(W):
    if S[front][w]=="#":
        m+=1
        for z in range(x,w+1):
            P[front][z]=m
        x=w+1
for z in range(x,W):
    P[front][z]=m

for h in range(front-1,-1,-1):
    for w in range(W):
        P[h][w]=P[h+1][w]


for h in range(front+1,H):
    if "#" in S[h]:
        x=0
        for w in range(W):
            if S[h][w]=="#":
                m+=1
                for z in range(x,w+1):
                    P[h][z]=m
                x=w+1
        for z in range(x,W):
            P[h][z]=m
    else:
        for w in range(W):
            P[h][w]=P[h-1][w]

for h in range(H):
    print(" ".join(list(map(str,P[h]))))


Measured memory_bytes: 43884
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    vector< pair<int,int> > a(n);
    int list[100002];
    int ans = 0;
    memset(list,0,sizeof(list));
    REP(i,n){
	int t;
	cin >> t;
	a[i] = make_pair(t,i+1);
    }
    sort(ALL(a));
    REP(i,n){
	int v = l-a[i].first;
	int m = a[i].second;
	list[m] = max(list[m-1]+v,list[m+1]+v);
	ans = max(ans,list[m]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2324
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int s = scan.nextInt();
        int b = scan.nextInt();

        while (n != 0 && s != 0 && b != 0) {
            int r = 0;
            int f = 0;
            int t[] = new int[n];
            for (int i = 0; i < n; i++) {
                t[i] = scan.nextInt();
            }
            for (int x = s; x <= b; x++) {
                int l = t[x - 1] - t[x];
                if (r <= l) {
                    r = l;
                    f = x;
                }
            }
            System.out.println(f);
            n = scan.nextInt();
            s = scan.nextInt();
            b = scan.nextInt();

        }
    }
}




Measured memory_bytes: 57092
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


int n;
string s;
long long ans;


int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> s;
    n = (int)s.size();
    --n;
    for (int i = 0; i < (1 << n); ++i) {
        long long last = 0;
        for (int j = 0; j <= n; ++j) {
            last *= 10;
            last += s[j] - '0';
            if (j < n && (i & (1 << j))) {
                ans += last;
                last = 0;
            }
        }
        ans += last;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using V = vector<int>;

void dfs(const int& u, const bool& b, const int& p, V& bipartite, const vector<V>& g, vector<V>& bi) {
    if (bipartite[u] >= 0) return;
    bipartite[u] = b;
    bi[b].push_back(u);

    for (auto v : g[u]) {
        if (v == p) continue;
        dfs(v, !b, u, bipartite, g, bi);
    }
}

int main() {
    int n;
    cin >> n;
    vector<V> g(n+1);

    for (int i=1; i<n; i++) {
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }


    V bipartite(n+1, -1);
    vector<V> bi(2);

    dfs(1, false, -1, bipartite, g, bi);
    vector<vector<int>> m(3);
    for (int i=1; i<=n; i++) {
        m[i%3].push_back(i);
    }


    if (bi[0].size() > bi[1].size()) swap(bi[0], bi[1]);


    debug(bi);
    debug(m);

    vector<int> ans(n+1, -1);

    if (bi[0].size() <= n/3) {
        for (auto b : bi[0]) {
            ans[b] = m[0].back();
            m[0].pop_back();
        }
        for (auto b : bi[1]) {
            if (!m[1].empty()) {
                ans[b] = m[1].back();
                m[1].pop_back();
            } else if (!m[2].empty()) {
                ans[b] = m[2].back();
                m[2].pop_back();
            } else {
                ans[b] = m[0].back();
                m[0].pop_back();
            }
        }
    } else {

        for (int i=1; i<=2; i++) {
            for (auto b : bi[i-1]) {
                if (!m[i].empty()) {
                    ans[b] = m[i].back();
                    m[i].pop_back();
                } else {
                    ans[b] = m[0].back();
                    m[0].pop_back();
                }
            }
        }
    }


    // ans に全て値が入っていなかったら 1 を返す（RE）
    auto any = [](const int& x) {return x<0;};
    if (any_of(ans.begin()+1, ans.end(), any)) {
        return 1;
    }

    for (int i=1; i<=n; i++)
        cout << ans[i] << (i!=n? " " : "\n");
}


Measured memory_bytes: 24180
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  rep(i,3){
    if(s.substr(i,1) == "7"){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 3632
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
count=0
for i in range(K):
    if i<N%K and N%K!=0:
        L=len(T)//K+1
    else:
        L=len(T)//K
    previous=""
    for j in range(L):
        if T[K*j+i]==previous:
            previous=""
        elif T[K*j+i]=="s":
            count+=R
            previous="s"
        elif T[K*j+i]=="r":
            count+=P
            previous="r"
        else:
            count+=S
            previous="p"
print(count)

Measured memory_bytes: 3316
n = int(input())
li = [input().split() for i in range(n)]

ans = 0

for i in range(n):
    li[i][0] = float(li[i][0])
    if li[i][1] == "JPY":
        ans += li[i][0]
    else:
        ans += li[i][0]*380000

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

#define big ((long long)(1e9)+7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  if(s.size()%2 != 0)
  {
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0;i < s.size();i++)
  {
    if(i%2 == 0)
    {
      if(s.at(i) != 'h')
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else if(i%2 == 1)
    {
      if(s.at(i) != 'i')
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main() {
  int H, W;
  cin >> H >> W;

  int h = H / 3;
  int w = W / 3;

  int ans = INF;

  int m, M;

  int a, b, c;

  a = h * W;
  b = (H - h) / 2 * W;
  c = H * W - a - b;
  m = min(min(a, b), c);
  M = max(max(a, b), c);
  ans = min(ans, M - m);

  b = (H - h) * (W / 2);
  c = H * W - a - b;
  m = min(min(a, b), c);
  M = max(max(a, b), c);
  ans = min(ans, M - m);


  a = (h + 1) * W;
  b = (H - h - 1) / 2 * W;
  c = H * W - a - b;
  m = min(min(a, b), c);
  M = max(max(a, b), c);
  ans = min(ans, M - m);

  b = (H - h - 1) * (W / 2);
  c = H * W - a - b;
  m = min(min(a, b), c);
  M = max(max(a, b), c);
  ans = min(ans, M - m);



  a = w * H;
  b = (W - w) / 2 * H;
  c = H * W - a - b;
  m = min(min(a, b), c);
  M = max(max(a, b), c);
  ans = min(ans, M - m);

  b = (W - w) * (H / 2);
  c = H * W - a - b;
  m = min(min(a, b), c);
  M = max(max(a, b), c);
  ans = min(ans, M - m);


  a = (w + 1) * H;
  b = (W - w - 1) / 2 * H;
  c = H * W - a - b;
  m = min(min(a, b), c);
  M = max(max(a, b), c);
  ans = min(ans, M - m);

  b = (W - w - 1) * (H / 2);
  c = H * W - a - b;
  m = min(min(a, b), c);
  M = max(max(a, b), c);
  ans = min(ans, M - m);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
        string s;
        int q;
        cin >> s;
        cin >> q;
        deque<char> dq;
        rep(i,(int)s.size()){
                             dq.push_back(s.at(i));
        }
        
        int cnt = 0;
        rep(i,q){
                 int t;
                cin >> t;
                if(t==1) cnt ++;
                else{
                        int f;
                        char c;
                        cin >>f >> c;
                        if(f==1){
                                if(cnt%2 ==0) dq.push_front(c);
                                else dq.push_back(c);
                        }else{
                                if(cnt%2 ==0) dq.push_back(c);
                                else dq.push_front(c);
                        }
                }
        }
                                
        if(cnt%2 ==1) reverse(dq.begin(),dq.end());
        
        for(char p:dq) cout << p ;
        cout << endl;
        
        
        
        return 0;
}




Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long 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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (ll b = k+1; b <= n; ++b) {
        ans += ((n+1)/b)*(b-k) + max(0LL, (n+1)%b-k);
    }
    if (k == 0) ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
      num = num * (n - i + 1) / i;
  }
  return num;
}
int main(void)
{
	int N, M;
	cin >> N >> M;
	int ans = Combination(N, 2) + Combination(M, 2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * Created by abhishek on 8/4/2016.
 */
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int array[] = new int[n + 1];
        int temp[] =  new int[n + 1];
        temp[0] = -1;
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            int a = Integer.parseInt(br.readLine());
            array[i] = a;
            temp[i] = a;
        }
        Arrays.sort(temp);
        for(int i = 1;i <= n;i++){
            int pos = Arrays.binarySearch(temp,array[i]);
            map.put(array[i],pos);
        }
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            int pos = map.get(array[i]);
            //System.out.println(array[i] + " " + pos + " " + i);
            if(pos > i && ((pos - i) & 1) == 1)
                cnt++;
            else if (((i - pos) & 1) == 1) cnt++;
        }
        System.out.println((int) Math.ceil(cnt * 1.0 / 2));
    }
}


Measured memory_bytes: 28464
n,w=map(int,input().split())
wv=[]
for i in range(n):
    wv.append(tuple(map(int,input().split())))
dp=[[0]*(w+1) for _ in range(n+1)]
for i in range(1,n+1):
    wei,val=wv[i-1]
    for j in range(1,w+1):
        if 0<=j-wei<=w:
            dp[i][j]=max(dp[i-1][j], dp[i-1][j-wei]+val)
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])

Measured memory_bytes: 120172
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MOD = 998244353;
int ksm(int a,int b){
    int ans=1;
    while(b){
        if(b&1)
            ans=(1LL*ans*a)%MOD;
        a=(1LL*a*a)%MOD;
        b>>=1;
    }
    return ans;
}
int fac[1001010],fac_inv[1001010];
void init(int N){
    fac[0]=1;
    for(int i=1;i<=N;i++)
        fac[i]=(1LL*fac[i-1]*i)%MOD;
    fac_inv[N]=ksm(fac[N],MOD-2);
    for(int i=N-1;i>=0;i--)
        fac_inv[i]=(1LL*fac_inv[i+1]*(i+1))%MOD;
}
int C(int n,int m){
    return 1LL*fac[n]*fac_inv[m]%MOD*fac_inv[n-m]%MOD;
}
int work(int n,int m){
    return C(n+m,n);
}
int inv2,ans=0,tmp=0,n,m;
int main(){
    init(1001000);
    inv2=ksm(2,MOD-2);
    scanf("%d %d",&n,&m);
    ans=max(n,m);
    for(int i=1;i<=min(n,m);i++){
        tmp=(tmp+1LL*work(i,i)*work(n-i,m-i)%MOD)%MOD;
    }
    tmp=(1LL*tmp*inv2)%MOD;
    tmp=(1LL*tmp*ksm(work(n,m),MOD-2))%MOD;
    ans+=tmp;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
 #include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r   ///ºê
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 1000005
#define maxn 100005
typedef pair<int,int> PII;
typedef long long LL;

int n,m,k,cnt,L,R,now,last;
int a[maxn];
int dp[20][maxn];


int main(){
    //freopen("in.txt","r",stdin);
    int i,j,x,y,last=1;
    scanf("%d",&n);
    for(i=1;i<=n;++i)scanf("%d",&a[i]);
    scanf("%d",&k);
    for(i=1;i<=n;++i){
        while(a[i]-a[last]>k)++last;
        dp[0][i]=last;
    }
    for(i=1;i<20;++i)
    for(j=1;j<=n;++j)
    dp[i][j]=dp[i-1][dp[i-1][j]];
    scanf("%d",&m);
    while(m--){
        int ans=0;
        scanf("%d%d",&x,&y);
        if(x>y)swap(x,y);
        for(i=16;i>=0;--i){
            if(dp[i][y]>x){
                ans+=(1<<i);
                y=dp[i][y];
            }
        }
        printf("%d\n",ans+1);
    }
    return 0;
}


Measured memory_bytes: 8960
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//#define int long long

ll dp[(1<<18)][20];

void solve() {
	int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    rep(i, 1<<18) {
        rep(j, 20) {
            dp[i][j] = INF;
        }
    }
    rep(i, n) {
        dp[(1<<i)][i] = 0;
    }
    rep(s, (1<<n)) {
        int c = __builtin_popcount(s);
        rep(i, n) {
            if(!(s & (1<<i))) continue;
            int x = ((c - 1 - i) % 2 == 0 ? a[i] : b[i]);
            int co = c;
            rep(j, n) {
                if(s & 1<<j) {
                    --co;
                    continue;
                }
                else {
                    int y = ((c - j) % 2 == 0 ? a[j] : b[j]);
                    if(x <= y) {
                        chmin(dp[s | 1<<j][j], dp[s][i] + co);
                    }
                }
            }
        }
    }
    ll ans = INF;
    rep(i, n) {
        chmin(ans, dp[(1<<n) - 1][i]);
    }
    if(ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 41344
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

a_set = {int(input()) for _ in range(m)}

ans_list = []

ans_list = [0] * (n + 1)

for index in range(n + 1):
    if index == 0:
        ans_list[index] += 1
        continue
    if index == 1 and (index not in a_set):
        ans_list[index] += ans_list[index - 1]
        continue

    if index not in a_set:
        if (index - 1) not in a_set:
            ans_list[index] += ans_list[index - 1]
            ans_list[index] %= 1000000007
        if (index - 2) not in a_set:
            ans_list[index] += ans_list[index - 2]
            ans_list[index] %= 1000000007

print(ans_list[n])


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

typedef long long int64;
int64 k;

int main() {
	scanf("%lld", &k);

	int64 c = k / 50;
	int64 r = k % 50;

	if(c == 0) {
		if(k == 0) {
			printf("2\n0 0\n");
			return 0;
		}

		if(k == 1) {
			printf("2\n2 0\n");
			return 0;
		}

		printf("%lld\n", k);

		for(int i = 1; i <= k; i++) {
			printf("%lld", k);
			printf(i == k ? "\n" : " ");
		}

		return 0;
	}

	printf("50\n");

	for(int i = 1; i <= r; i++)
		printf("%lld ", 50 + c - i + 1);

	for(int i = 1; i <= 50 - r; i++) {
		printf("%lld", 49 + c - r);
		printf(i == 50 - r ? "\n" : " ");
	}

	return 0;
}

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

using ll = long long;

int main() {
    const ll mod = 998244353;
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> kukan(k);
    for (int i = 0; i < k; ++i) {
        cin >> kukan[i].first >> kukan[i].second;
    }
    vector<ll> dp(2*n+1, 0);
    vector<ll> ssum(k, 0);
    dp[n] = 1;
    for (int i = n+1; i < 2*n+1; ++i) {
        ll sum = 0;
        for (int j = 0; j < k; ++j) {
            ssum[j] = (ssum[j] - dp[i-kukan[j].second-1] + dp[i-kukan[j].first] + mod) % mod;
            (sum += ssum[j]) %= mod;
        }
        (dp[i] += sum) %= mod;
    }
    cout << dp[2*n-1] << endl;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f3f3f3f3f
#define PI acos(-1.0)
#define MOD 1000000007
//#define eps 1e-10
#define R freopen("555input.txt","r",stdin);
#define W freopen("555output.txt","w",stdout);
//
#define N 100005
#define M 1000000005
int n,num4 ,num2,i,t;
int main ()
{
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&t);
        if(t%2==0)if(t%4==0)num4++;
        else num2++;
    }
    if(num4*2+num2>=n||num2==0&&num4*2+1==n)printf("Yes\n");
    else printf("No\n");
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

char a[100];
int flag[100];
int pp = 0;
int main()
{
	scanf("%s", a);
	int len = strlen(a);
	for(int i = 0; i <= len - 1; i++)
	{
		flag[a[i] - 'a']++;
	}
	for(int i = 0; i <= 99; i++)
	{
		if(flag[i] > 1) pp = 1;
	}
	if(pp == 1) printf("no\n");
		else printf("yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(min(a,b)>0) cout<<"Positive"<<endl;
    else if(max(a,b)>0) cout<<"Zero"<<endl; 
    else if((a-b)%2==0) cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
    return 0;
}

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

const int maxn = 103;

char map[maxn][maxn];
int move [][2] = {{0,1},{1,0},{0,-1},{-1,0}};
int n , m;
int ans;

void dfs ( int i , int j ){
	char temp = map[i][j];
	map[i][j] = '.';
	for(int k = 0 ; k < 4 ; k ++){
		if((i+move[k][0]>0)&&(i+move[k][0]<=n)&&(j+move[k][1]>0)&&(j+move[k][1]<=m)&&map[i+move[k][0]][j+move[k][1]]==temp){
			dfs(i+move[k][0],j+move[k][1]);
		}
	}
}



int main(void){
	while(cin>>n>>m){
		if((!n)&&(!m))break;
		ans = 0;
		for(int i = 1 ; i <= n ; i ++){
			for(int j = 1 ; j <= m ; j ++){
				cin>>map[i][j];
			}
		}
		for(int i = 1 ; i <= n ; i ++){
			for(int j = 1 ; j <= m ; j ++){
				if(map[i][j]!='.'){
					dfs(i,j);
					ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
		
}

Measured memory_bytes: 1632
import sys
def input(): return sys.stdin.readline().strip()

def main():
    a, b, c = map(int, input().split())
    if a == 5 and b == 5 and c == 7:
        print("YES")
        return
    if b == 5 and c == 5 and a == 7:
        print("YES")
        return
    if c == 5 and a == 5 and b == 7:
        print("YES")
        return
    print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61832
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, M, K = map(int, input().split())
    for i in range(N+1):
        for j in range(M+1):
            S = (M-j)*(N-i)+i*j
            if S == K:
                print('Yes')
                break
        else:
            continue
        break
    else:
        print('No')

if __name__ == '__main__':
    main()


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

int digitSum(int x) {
    string s = to_string(x);
    int ans = 0;
    for (char i : s) ans += i - '0';
    return ans;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; ++i) if (a <= digitSum(i) && digitSum(i) <= b) ans += i;
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var list: MutableList<Int> = mutableListOf()
    val n = readLine()!!.toInt()
    var count = 0
    while (count < n) {
        list.add(readLine()!!.toInt())
        count++
    }
    var min = list.get(0)
    var max = -2147483648
    for (i in 0 until n - 1) {
        min = Math.min(min, list.get(i))
        max = Math.max(max, list.get(i + 1) - min)
    }
    println(max)
}


Measured memory_bytes: 49596
#include<bits/stdc++.h>
using namespace std;
#define int long long int

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    b[0]=a[0];
    for(i=1;i<n;i++){
        b[i]=__gcd(a[i],b[i-1]);
    }
    b.insert(b.begin(),0);
    c[n-1]=a[n-1];
    for(i=n-2;i>=0;i--){
        c[i]=__gcd(a[i],c[i+1]);
    }
    c.push_back(0);
    // for(i=0;i<n;i++){
    //     cout<<a[i]<<"\t"<<b[i]<<"\t"<<c[i]<<'\n';
    // }
    vector<int> f(n);
    for(i=0;i<n;i++){
        f[i]=__gcd(b[i],c[i+1]);
    }
    sort(f.begin(),f.end(),greater<int>());
    cout<<f[0]<<'\n';
    return 0;
}

Measured memory_bytes: 3456
using System;

namespace _0000
{
    class Program
    {
        static void Main(string[] args)
        {
            const int MAXNUMBER = 9;

            for (int firstNumber = 1; firstNumber <= 9 ;firstNumber++)
            {
                for (int secondNumber = 1; secondNumber <= 9; secondNumber++)
                {
                    Console.WriteLine("{0}x{1}={2}", firstNumber, secondNumber, firstNumber * secondNumber);
                }
            }
        }
    }
}

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

int main() {
    int a, b;

    cin >> a >> b;

    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}


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

bool iscat(const string& S) {
    unsigned p = 0;
    function<bool()> ll = [&] {
        if (S.empty()) return true;
        if (S[p] != 'm') return false;
        p++;
        if (S[p] != 'e') if (!ll() || S[p] != 'e') return false;
        p++;
        if (S[p] != 'w') if (!ll() || S[p] != 'w') return false;
        p++;
        return true;
    };
    return ll() && p == S.size();
}

int main() {
    string S; cin >> S;
    cout << (iscat(S) ? "Cat" : "Rabbit") << endl;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
int N;
int ans = -1;
vector<vector<int>> graph;
vector<vector<bool>> reached;

void dfs(int y,int x,int cnt){
    if(y>=2 || x>=N) return;
    
    cnt += graph[y][x];
    if(y == 1 && x == N-1){
        ans = max(ans,cnt);
        return;
    }
    dfs(y,x+1,cnt);
    dfs(y+1,x,cnt);
}

int main(){
    cin >> N;
    graph = vector<vector<int>>(2,vector<int>(N));
    reached = vector<vector<bool>>(2,vector<bool>(N));
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            cin >> graph[i][j];
        }
    }
    dfs(0,0,0);
    cout << ans << endl;

}


Measured memory_bytes: 256