akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD 1000000007
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int BIG=pow(2,20);
const int N=100005;
 int32_t main(){
          getFaster;
          int n;
          cin>>n;
          string str;
          cin>>str;
          int l=n/2;
          if(n&1){cout<<"No"<<endl;return 0;}
          bool g=true;
          rep(i,0,l)
          {
             if(str[i]!=str[i+l])
             {
              g=false;
              break;
             } 
          }
          if(g)cout<<"Yes"<<endl;
          else cout<<"No"<<endl;
          return 0;
}

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

int main(){
  ll s,w;
  cin >> s >> w;
  if( w >= s ){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    d = defaultdict(lambda: 0)
    S = str(input().strip())
    for s in S:
        d[s] += 1

    if len(d.keys()) != 2:
        return 'No'

    for k, v in d.items():
        if v != 2:
            return 'No'

    return 'Yes'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(void){

	string DATA;
	while(cin >> DATA){
		int JOI = 0,IOI = 0;
		for(int i = 0; i < DATA.size()-3; i++){
			string S;
			for(int j = 0; j < 3; j++){
				S += DATA[i+j];
				//cout << S << endl;
				if(S == "JOI")JOI++;
				if(S == "IOI")IOI++;
			}
		}
		cout << JOI << endl;
		cout << IOI << endl;
	}

}

Measured memory_bytes: 1208
n = int(input())
c = [[0] * 10 for _ in range(10)]

for i in range(1, n + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    c[a][b] += 1

res = 0
for i in range(10):
    for j in range(10):
        res += c[i][j]*c[j][i]
print(res)


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

int main(){
  int n,m;
  cin>>n>>m;
  
  vector<int> h(n);
  vector<bool> p(n,true);
  
  for (int i=0;i<n;i++) {
    cin>>h[i];
  }
  
  for (int j=0;j<m;j++){
  	int a,b;
    cin>>a>>b;
    a=a-1;
    b=b-1;
    if(h[a]<=h[b]) p[a]=false;
    if(h[b]<=h[a]) p[b]=false;
  }
  
  int ans=0;
  for(int k=0;k<n;k++){
  	if(p[k]) ans++;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3736
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//213
	int n;
	cin>>n;
	n--;
	ll a,b;
	cin>>a>>b;
	while(n--) {
		ll c,d;
		cin>>c>>d;
		ll mula = a/c;if(mula*c!=a)mula++;
		ll mulb = b/d;if(mulb*d!=b)mulb++;
		ll mul = max(mula,mulb);
		a=c*mul,b=d*mul;
	}
	cout<<a+b;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3600
#include<stdio.h>

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    int a[n];
    
    for (int i = 0; i < n; i++) // taking all the scores
	{
        scanf("%d", &a[i]);
    }
    
    for (int i = k; i < n; i++) // loop for checking
	{
        if (a[i - k] < a[i])
		{
            puts("Yes");
        }
		else
		{
            puts("No");
        }
    }
    
    return 0;
}

Measured memory_bytes: 2424
n, m = gets.strip.split.map(&:to_i)
a = n.times.map{ gets.strip.split("") }
b = m.times.map{ gets.strip.split("") }

def foo(bar, baz, m, b, a)
    hoge = 0
    m.times do |i|
        b[0].length.times do |j|
            hoge = 1 if a[bar + i][baz + j] != b[i][j]
            break if hoge == 1
        end
        break if hoge == 1
    end
    return hoge
end

fuga = 0
(n - m + 1).times do |i|
    (a[0].length - b[0].length + 1).times do |j|
        fuga = 1 if foo(i, j, m, b, a) == 0
        break if fuga == 1
    end
    break if fuga == 1
end

puts fuga == 1 ? "Yes" : "No"

Measured memory_bytes: 1916
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main() {
  int a, b, c;

  cin >> a >> b >> c;
  int ans = max({
      10 * a + b + c,
      a + 10 * b + c,
      a + b + 10 * c,
    });
  cout << ans << endl;
}

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

int main(){
    int x;
    cin>>x;
    
    int ans=1;
    while(1){
        if((ans*x)%360==0){
            cout<<ans<<endl;
            return 0;
        }
        ans++;
    }
}


Measured memory_bytes: 3544
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n,l;
	cin >> n >> l;
	vector<string> s(n);
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	sort(s.begin(),s.end());
	for(int i=0;i<n;i++){
		cout << s[i];
	}
	cout << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL vec(n);rep(i,n)cin>>vec[i]
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,maxSpeed]:a)cout<<k<<":"<<maxSpeed<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
typedef struct{ll to;ll cost;} Graphs;
typedef V<V<Graphs>> AdjList;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

void print(){}
template<class Head,class... Tail>
void print(Head&& head, Tail&&... tail){
  cout<<head<<endl;
  print(forward<Tail>(tail)...);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int n;
  cin>>n;
  V<D> t(n),v(n);
  rep(i,n)cin>>t[i];
  rep(i,n)cin>>v[i];
  
  D T=0.0;
  rep(i,n)T+=t[i];
  V<D> speed(T*2+1,0),limit(T*2+1,1e9+7);
  int idx=0,sum=0;
  rep(i,n){
    rep(j,t[i]*2){
      chmin(limit[idx],v[i]);
      idx++;
    }
    sum+=t[i];
    if(i+1<n){limit[2*sum]=min(v[i],v[i+1]);}
  }
  
  //rep(i,2*T+1){cout<<(D)i/2<<" "<<limit[i]<<endl;}
  limit[0]=limit[2*T]=0;
  rep(as,2*n){
    for(int i=1;i<=2*T;++i){
      speed[i]=min(limit[i],max(speed[i],speed[i-1]+0.5));
      limit[i]=speed[i];
    }
    for(int i=2*T;i>0;--i){
      speed[i]=min(limit[i],min(speed[i],speed[i+1]+0.5));
      limit[i]=speed[i];
    }
  }
  //rep(i,2*T+1){cout<<(D)i/2<<" "<<speed[i]<<endl;}
  D ans=0.0;
  rep(i,2*T)ans+=((speed[i]+speed[i+1])/4);
  out(ans);

  return 0;
}

Measured memory_bytes: 896
{-# LANGUAGE BangPatterns #-}
import Control.Applicative((<$>))
import Control.Monad
import Data.Map ((!))
import qualified Data.Map as M
-- import Data.IntMap ((!))
-- import qualified Data.IntMap as M
import qualified Data.List as L
import Data.Maybe (catMaybes)
-- import qualified Data.Char as C
-- import qualified Data.IntSet as I
import Debug.Trace
--------------------------------------------
readInt    = read :: String -> Int
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
int2bin 0 =  []
int2bin n =  n `mod` 2 : int2bin (n `div` 2)
----------------------------------------------

main :: IO ()
main = do
  [n, k] <- getIntList
  putStrLn $ if even n
  then if n `div` 2 - k >= 0 then "YES" else "NO"
  else if (n + 1) `div` 2 - k >= 0 then "YES" else "NO"

Measured memory_bytes: 508
#include <iostream>
#include <set>
#define NUM_PEOPLE 5
using namespace std;


bool aiko(int* h);
int win(int* h);

int main(void){
  int h[NUM_PEOPLE];
  int retval[NUM_PEOPLE];
  while(true){
    for(int i=0;i<NUM_PEOPLE;i++){
      cin>>h[i];
      if(h[i]==0){return 0;}
    }
    if(aiko(h)){
      for(int i=0;i<NUM_PEOPLE;i++){
        retval[i]=3;
      }
    }
    else{
      int w=win(h);
      for(int i=0;i<NUM_PEOPLE;i++){
        if(h[i]==w){
          retval[i]=1;
        }
        else{
          retval[i]=2;
        }
      }
    }
    for(int i=0;i<NUM_PEOPLE;i++){
      cout<<retval[i]<<endl;
    }
  }
}

bool aiko(int* h){
  set<int> st(h,h+NUM_PEOPLE);
  int count=0;
  for(auto iter=st.begin();iter!=st.end();iter++){
    count++;
  }
  return count==3 or count==1;
}

int win(int* h){
  set<int> st(h,h+NUM_PEOPLE);
  auto iter=st.begin();
  int h1=*iter;
  iter++;
  int h2=*iter;
  if((h1==1 and h2==2) or (h1==2 and h2==1)){
    return 1;
  }
  else if((h1==3 and h2==2) or (h1==2 and h2==3)){
    return 2;
  }
  else{
    return 3;
  }
}



Measured memory_bytes: 3032
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}


const ll N=2e5+5;

 
int main()
{ 

IOS;

ll n;cin>>n;

set<ll>s;

ll val=0;

FOR(i,n){
  ll x;cin>>x;
  s.insert(x^(x-1));
  val=val^x;
}

ll cnt=0;


if(!val){
  cout<<0<<endl;
return 0;
}

//d1(val);

for(ll i=32;i>=0;i--){
  ll temp=0;
  if((1ll<<i)&val)temp=1;
  //d2(cnt,temp);
  //temp=(temp+cnt)%2;
  if(temp==1){
    ll x=(1ll<<i);
    if(s.count(2*x-1))cnt++,val=val^(2*x-1);
    else {
      cout<<-1;
      return 0;
    }
  }
}

d1(cnt);

//end_routine();

return 0;
 
 }


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
main(){
long long n,m,p;
 vector<long long> d;
 cin>>n>>m>>p;
 for(int i=0;i<m;i++){
   long long pos;
   cin>>pos;
   d.push_back(pos);
 }
 sort(d.begin(),d.end());
 long long nearnext=0;
 long long nextf=0;
 long long nearback=m-1;
 for(int i=0;i<m;i++){
   if(p<d[i]&&nextf==0){
     nextf=1;
     nearnext=i;
   }
   if(p>d[i]){
     nearback=i;
   }
 }
 long long ans;
 if(d[nearback]<p){
   ans=d[nearback]+n-p;
 }
 else{
   ans=d[nearback]-p;
 }
 //cout<<ans*100<<endl;
 if(d[nearnext]>p){
   ans=min(ans,p+n-d[nearnext]);
 }
 else{
   ans=min(ans,p-d[nearnext]);
 }
 //cout<<ans*100<<endl;
 for(int i=0;i<m;i++){
   long long ret=d[i];
   long long goal=d[(i+1)%m];
   long long go,back;
   if(ret<p){
     go=ret+n-p;
   }
   else{
     go=ret-p;
   }
   if(goal>p){
     back=p+n-goal;
   }
   else{
     back=p-goal;
   }
   ans=min(ans,go*2+back);
 }
 //cout<<ans*100<<endl;
 for(int i=0;i<m;i++){
   long long ret=d[i];
   long long goal=d[(i+1)%m];
   long long go,back;
   if(ret<p){
     go=ret+n-p;
   }
   else{
     go=ret-p;
   }
   if(goal>p){
     back=p+n-goal;
   }
   else{
     back=p-goal;
   }
   ans=min(ans,go+back*2);
 }
 cout<<ans*100<<endl;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double n,t,A;
double a[1001],b[1001];
void Solve(){
    cin>>n;
    cin>>t>>A;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        b[i]=t-a[i]*0.006;
    }
    double min=100000000;
    int min_i=100001;
    for(int i=0;i<n;i++){
        if(abs(b[i]-A)<min){
            min=abs(b[i]-A);
            min_i=i;
        }
    }
    cout<<min_i+1<<endl;
}
int main(){
    Solve();
    return 0;
}

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

//for test in *.in; do echo $test; ./a.out < $test ; done
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define pb push_back
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define MOD 1000000007
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main(){
	int n;
	cin >> n;
	vector<int> A(n);
	bool fl = true;
	for(auto &a:A){
		cin >> a;
		if(a%2==0){
			if(a%3!=0 and a%5!=0)
				fl = false; 
		}
	}
	cout << (fl?"APPROVED\n":"DENIED\n");
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}







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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;
  int n = s.size() - 1;

  int64_t ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    int64_t tmp = (s[0] - '0');
    cerr << s[0];
    int64_t sum = 0;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        sum += tmp;
        tmp = (s[j + 1] - '0');
        cerr << "+"s;
      } else {
        tmp *= 10;
        tmp += (s[j + 1] - '0');
      }
      cerr << s[j + 1];
    }
    sum += tmp;
    ans += sum;
    cerr << " " << sum << '\n';
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
 string s;
 cin >> s;
 ll sum=0;
 int n=s.size();
 rep(i,n){
   int x=s.at(i)-'0';
   sum+=x;
 }
 if(sum%9==0)cout << "Yes" << endl;
 else cout << "No" << endl;

}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N; int ans;
int DFS(ll num, bool three, bool five, bool seven){
  if (num > N) return 0;

  if (three && five && seven) ans++;
  DFS(num*10+3, 1, five, seven);
  DFS(num*10+5, three, 1, seven);
  DFS(num*10+7, three, five, 1);

  return 0;
}

int main(){
  cin >> N;
  DFS(0,0,0,0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	int cnt = 0;
	int minj = 0;
	for (int i = 0; i < N; i++) {
		minj = i;
		for (int j = i; j < N; j++) {
			if (A[minj] > A[j])minj = j;
		}
		if (A[i] != A[minj]) {
			swap(A[i], A[minj]);
			cnt++;
		}
	}
	rep(i, N) {
		cout << A[i];
		if (i != N - 1)cout << ' ';
	}
	cout << endl << cnt << endl;
}


Measured memory_bytes: 3092
import bisect
ss = input()
ss =list(map(ord, ss))
dic = [i for i in range(97,123)]
# print(dic)
for s in ss:
    dic.remove(s)
# print(dic)
if len(ss)<26:
    ss.append(min(dic))
else:
    for s in ss[::-1]:
        if len(dic)>0 and s < max(dic):
            ss[ss.index(s)] = dic[bisect.bisect_right(dic,s)]
            break
        dic.append(ss.pop(ss.index(s)))
        dic = sorted(dic)
    else:
        ss = -1
print(ss if ss == -1 else ''.join(list(map(chr,ss))))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
	int l, r, d;
	cin >> l >> r >> d;

	int ans = 0;
	for (int i = l; i < r + 1; i++) {
		if (i % d == 0) {
			ans += 1;
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 3632
import math
def C(n, k):
    return math.factorial(n) / math.factorial(k) / math.factorial(n - k)

n, p = map(int, raw_input().split())
a = [int(i) for i in raw_input().split()]

even = 0
for ai in a:
  if ai % 2 == 0:
    even += 1
 
odd = len(a) - even
ans = 0

for x in range(0, even + 1):
    for y in range(0, odd + 1):
        if (y % 2 == p):
            ans += C(even, x) * C(odd, y)
print ans

Measured memory_bytes: 2692
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(Math.abs(C-A) <= D || (Math.abs(B-A) <= D && Math.abs(C-B) <= D)) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 22356
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,a,b,ans[100005]={};
  cin >> n >> m;
  for(int i=1; i<=n; i++) {
    ans[i]=-1;
  }
  ans[1]=0;
  vector<int> g[100005];
  for(int i=0; i<m; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q;
  q.push(1);
  while(q.size()) {
    int p=q.front();
    q.pop();
    for(auto v:g[p]) {
      if(ans[v]==-1) {
        ans[v]=p;
        q.push(v);
      }
    }
  }
  cout << "Yes" << "\n";
  for(int i=2; i<=n; i++) {
    cout << ans[i] << "\n";
  }
}

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

#define   Pi     2*acos(0.0)
#define   LINF   1LL<<63
#define   ll     long long
#define   ull    unsigned long long
#define   pb     push_back
#define   mp     make_pair
#define   MAX    500006
#define   MAX1   10000008
#define   mem(a,v)   memset(a,v,sizeof(a))
#define   all(x) x.begin(),x.end()
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define yes   cout<<"YES"<<endl
#define no   cout<<"NO"<<endl
#define buga  cout<<1<<endl
#define bugb  cout<<2<<endl
#define bugc  cout<<3<<endl
#define bugd  cout<<4<<endl
#define buge  cout<<5<<endl

void fastIO (){ios_base::sync_with_stdio(false);cin.tie(0); cout.precision(20);}

ll A[MAX];
ll B[MAX];
ll C[MAX];
vector< ll >V;
vector< ll >Ans;
vector< pair<ll,ll> >VP;
map< ll,ll >M;
vector<ll>prime;
bool mark[MAX1];
ll N=1e7;
void seive (){int limit = sqrt(N*1.0)+2;mark[1]=1;for (int i=4;i<=N;i+=2)mark[i]=1;prime.push_back(2);for (int i=3;i<=N;i+=2){if(!mark[i]){prime.push_back(i);if(i<=limit){for (int j=i*i;j<=N;j+=i*2)mark[j]=1;}}}}

/*
ll bin_pow(ll o, ll s) {
    if (s == 0) return 1;
    if (s == 1) return o % mod;
    ll d = bin_pow(o, s/2);
    d = (d * 1ll * d) % mod;
    if (s % 2 == 1)
        d = (d * 1ll * o) % mod;
    return d;
}
*/

int main ()
{
    fastIO();
    ll a,b,c,d,n,m,k,l,p,q,r,t,x,y;
    ll cnt=0,cntr=0,sum=0,ans=1,check=0;
    ll Max= 0,Max1=-1e18+1,Min=LINF;
    string s,s1,s3,s4;

    //cin>>n;
    //cin>>t;
    t=1;

    while(t--){
        cin>>n;
        //vector<ll>VV(n-1,0);
        for(int i=1;i<=n;i++){
            cin>>A[i];
        }
        ll mm=1e9+7;
        for(int i=n-1;i>=1;i--){
            B[i]=B[i+1]+A[i+1];B[i]%=mm;
        }

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

            a=(A[i]%mm*B[i]%mm)%mm;sum=sum%mm+a%mm;sum%=mm;
        }
        cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 6808
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vll vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//以上テンプレ

int main(){
    ll t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    ll s1,s2;
    s1=a1-b1;
    s2=a2-b2;
    if(s1<0){
        s1*=-1;
        s2*=-1;
    }
    ll count=0;
    ll dis=0;
    ll check=0;//0か1か-1
        if(s1*t1+s2*t2==0){
            cout<<"infinity"<<endl;
            return 0;
        }
        else if(s1*t1+s2*t2>0){
            cout<<0<<endl;
            }else{
                ll a,b;
                ll c=(s1*t1+s2*t2)*-1;
                a=s1*t1/c;
                b=s1*t1%c;
                if(b==0){
                    cout<<a*2<<endl;
                }else{
                    cout<<a*2+1<<endl;
                }
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int digitSum(int n){
  int sum=0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int n, num;
  cin >> n;
  num = digitSum(n);
  if(n % num == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main() {
  int N;
  string tmp;
  cin >> N;
  map<string, int> mp;
  
  for(int i=0; i<N; i++) {
    cin >> tmp;
    //if(mp[tmp]==0) mp[tmp] = 1;
    //else mp[tmp]++;
    mp[tmp]++;
  }
  
  /*for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    cout << "key = " << itr->first                // キーを表示
         << ", val = " << itr->second << "\n";    // 値を表示
  }*/
  
  //cout << ((judge==1) ? "APPROVED" : "DENIED") << endl;
  
  int max = 0;
  vector<string> list;
  for(auto itr=mp.begin(); itr!=mp.end(); ++itr) {
    if(itr->second == max) {
      list.push_back(itr->first);
    } else if(itr->second > max) {
      max = itr->second;
      list.erase(list.begin(), list.end());
      list.push_back(itr->first);
    }
  }
  
  for(int i=0; i<list.size(); ++i) {
    cout << list[i] << " " << endl; 
  }
  
  return 0;
}

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


def factorial_mod(n, mod):
    ret = 1
    for i in range(1, n + 1):
        ret *= i
        ret %= mod
    return ret


def main():
    N, M = map(int, input().split())

    mod = 10 ** 9 + 7
    factorial = factorial_mod(N, mod) * factorial_mod(M, mod)

    if abs(N - M) > 1:
        print(0)
    elif N == M:
        print((factorial * 2) % mod)
    else:
        print(factorial % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

ll r[2010][2010]={};
ll l[2010][2010]={};
ll u[2010][2010]={};
ll d[2010][2010]={};

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

  ll h,w;
  std::cin>>h>>w;

  std::vector<std::string> grid(h);
  rep(i,0,h)std::cin>>grid[i];

  rep(i,1,h+1){
    rep(j,1,w+1){
      if(grid[i-1][j-1]=='.')l[i][j]=l[i][j-1]+1;
      else l[i][j]=0;
    }
    for(ll j=w;j>0;j--){
      if(grid[i-1][j-1]=='.')r[i][j]=r[i][j+1]+1;
      else r[i][j]=0;
    }
  }

  rep(j,1,w+1){
    rep(i,1,h+1){
      if(grid[i-1][j-1]=='.')u[i][j]=u[i-1][j]+1;
      else u[i][j]=0;
    }
    for(ll i=h;i>0;i--){
      if(grid[i-1][j-1]=='.')d[i][j]=d[i+1][j]+1;
      else d[i][j]=0;
    }
  }

  ll ans=0;

  rep(i,1,h+1){
    rep(j,1,w+1){
      chmax(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3);
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 130688
fun main(args: Array<String>) {
    val (n, y) = readLine()!!.split(" ").map(String::toInt)

    val ans = Array(3) { -1 }
    for (a in 0..n) {
        for (b in 0..(n - a)) {
            val c = n - a - b
            if (calc(a, b, c) == y) {
                ans[0] = a
                ans[1] = b
                ans[2] = c
                break
            }
        }
    }
    println("${ans[0]} ${ans[1]} ${ans[2]}")
}

fun calc(a: Int, b: Int, c: Int): Int = 10000 * a + 5000 * b + 1000 * c



Measured memory_bytes: 38004
program name
    implicit none
    integer(8):: n,m
    integer(8),allocatable:: a(:),b(:),c(:),change(:)
    integer(8):: i,ci

    read*, n,m
    allocate(a(n), b(m), c(m))
    read*, a(:)

    do i=1_8, m
        read*, b(i), c(i)
    end do

    call merge_sort(a, 1_8, n)
    call double_sort(c,b, 1_8,m)

    do i=2,m
        b(i) = b(i)+b(i-1)
    end do

    allocate(change(n))
    change(:) = 0_8
    ci=1
    do i=1, m
    change(ci:min(b(i),n)) = c(i)
    ci = b(i)+1

    if(ci > n) exit
    end do

    do i=1,n
        a(i) = max(a(i),change(i))
    end do

    print*, sum(a)
contains
recursive subroutine double_sort(ar1, ar2, fst, lst)
    integer(8),intent(inout):: ar1(:),ar2(:)
    integer(8),intent(in):: fst,lst
    integer(8):: mdl

    if (lst - fst < 2) then
        if (ar1(fst) < ar1(lst)) then
            call swap(ar1(fst), ar1(lst))
            call swap(ar2(fst), ar2(lst))
        end if
        return
    end if

    mdl = (fst+lst)/2

    call double_sort(ar1,ar2,fst,mdl)
    call double_sort(ar1,ar2,mdl+1,lst)
    call double_merge_(ar1,ar2,fst,mdl,lst)
end subroutine


subroutine double_merge_(ar1,ar2,fst,mdl,lst)
    integer(8),intent(inout):: ar1(:),ar2(:)
    integer(8),intent(in):: fst,mdl,lst
    integer(8),allocatable:: t1(:),t2(:)
    integer(8):: li,ri,ti

    allocate(t1(lst-fst+1), t2(lst-fst+1))

    li=fst
    ri=mdl+1
    ti=1

    do while(li <= mdl .and. ri <= lst)
        if (ar1(li) >= ar1(ri)) then
            t1(ti) = ar1(li) 
            t2(ti) = ar2(li)
            li=li+1
        else
            t1(ti) = ar1(ri)
            t2(ti) = ar2(ri)
            ri=ri+1
        end if
        ti=ti+1
    end do

    if (li <= mdl) then
        t1(ti:) = ar1(li:mdl)
        t2(ti:) = ar2(li:mdl)
    else
        t1(ti:) = ar1(ri:lst)
        t2(ti:) = ar2(ri:lst)
    end if

    ar1(fst:lst) = t1(:)
    ar2(fst:lst) = t2(:)

    deallocate(t1,t2)
end subroutine


recursive subroutine merge_sort(ar, fst, lst)
    integer(8),intent(inout):: ar(:)
    integer(8),intent(in):: fst,lst
    integer(8):: mdl

    if (lst-fst < 2) then
        if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
        return
    end if

    mdl = (fst+lst)/2
    call merge_sort(ar, fst, mdl)
    call merge_sort(ar, mdl+1, lst)
    call merge_(ar, fst, mdl, lst)
end subroutine

subroutine merge_(ar, fst, mdl, lst)
    integer(8),intent(inout):: ar(:)
    integer(8),intent(in):: fst, mdl, lst
    integer(8),allocatable:: tmp(:)
    integer(8):: li, ri, ti

    allocate(tmp(lst-fst+1))

    li=fst
    ri=mdl+1   
    ti=1

    do while (li <= mdl .and. ri <= lst)
        if (ar(li) <= ar(ri)) then
            tmp(ti) = ar(li)
            li=li+1
        else
            tmp(ti) = ar(ri)
            ri=ri+1
        end if
        ti=ti+1
    end do

    if (li <= mdl) then
        tmp(ti:) = ar(li:mdl)
    else
        tmp(ti:) = ar(ri:lst)
    end if

    ar(fst:lst) = tmp(:)
    deallocate(tmp)
end subroutine

subroutine swap(x,y)
    integer(8),intent(inout):: x,y
    integer(8):: tmp
    tmp = x
    x = y
    y = tmp
end subroutine
end program name

Measured memory_bytes: 4644
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    int ans = n;
    rep(i,0,n-1){
        if(s[i]!=s[i+1]){
            chmin(ans,max(i+1,n-i-1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3724
c = input()
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

print(a[a.index(c)+1])

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

#define ll              long long
#define Ull             unsigned long long
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 2;
const ll MOD = 1e9 + 7;


void Solve()
{
	ll n;
	cin >> n;
	ll a[n], dp[n];
	for (ll i = 0; i < n; i++)
		cin >> a[i];

	for (ll i = 0; i < n; i++)
		dp[i] = INF;

	dp[0] = 0;
	for (ll i = 0; i < n - 1; i++)
	{
		dp[i + 1] = min(dp[i + 1], (dp[i] + abs(a[i + 1] - a[i])));
		if (i + 2 < n)
			dp[i + 2] = min(dp[i + 2], (dp[i] + abs(a[i + 2] - a[i])));

	}
	cout << dp[n - 1] << "\n";
}


int main()
{

	FastRead;
	int T = 1;
	//cin>>T;
	while (T--)
	{
		Solve();
	}

	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
void toggleAlphabet(char *str) {
	int i = 0;
	int diff = 'a' - 'A';
	while(str[i] != '\0') {
		if ('a' <= str[i] && str[i] <= 'z') {
			str[i] -= diff;
		}
		else if('A' <= str[i] && str[i] <= 'Z') {
			str[i] += diff;
		}
		i++;
	}
}
int main (){
	int length = 0;
	char str[1201];

	while((str[length] = getchar()) != '\n') length++;
	str[length] = '\0';

	toggleAlphabet(str);
	puts(str);
	return 0;
}

Measured memory_bytes: 524
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int [] arr = new int [n];
		for(int i=0;i<n;i++)
			arr[i]=sc.nextInt();
		int c=0;
		for(int i=1;i<n-1;i++)
			if(arr[i]>arr[i-1] && arr[i+1]>arr[i] ||( arr[i]<arr[i-1] && arr[i+1]<arr[i]))
				c++;
		System.out.println(c);
				
	}

}


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

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

  vector<int> a(n);
  //vectorに全入力値を代入する
  rep(i,n) cin >> a[i];

  int sum = 0;
  rep(i,n) {
    sum += a[i];
  }

  if (h - sum <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
def f(h, w):
    for i in range(h):
        if i % 2 == 0:
            x = ""
            for j in range(w):
                if j % 2 == 0:
                    x += "#"
                else:
                    x += "."
            print(x)
        else:
            x = ""
            for j in range(w):
                if j % 2 == 0:
                    x += "."
                else:
                    x += "#"
            print(x)


while True:
    h, w = map(int, input().split())
    if h == w == 0:
        break

    f(h, w)
    print()


Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
#define drep(i,n) for(int i = n; i >= 0; i--)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

int chmax(int& a,int b){
	if(b > a){
		a=b;
	}
	return a;
}
int chmin(int& a,int b){
	if(b < a){
		a=b;
	}
	return a;
}


int dp[10000+10000+10]={0};
int main(){
	int N,M;
	cin >> N >> M;
	fill(dp,dp+10000+10000+10,0);
	rep(f,N){
		int v,w;
		cin >> v >> w;
		for(int i=M;i>=0;i--){
			dp[i+w]=max(dp[i+w],dp[i]+v);
		}
	}
	cout << dp[M] << endl;

	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
 
using namespace std;
 
int main(){
    
    int N;
 
    cin >> N;
    
    int i;
    int ans = 0;
    int prev = -1;
    int count = 0;
    
    for(i=0;i<N;i++){
        int now;
        
        cin >> now;
        
        if(prev >= now){
            count++;
        }
        else{
            if(count > ans){
                ans = count;
            }
            count = 0;
        }
        
        prev = now;
        
    }
    
    if(count > ans){
                ans = count;
            }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;


int N;

bool check(const vector<pair<ld, ld>>&cs, const ld amid) {
	map<ld, int>mp;
	for (auto c : cs) {
		const ld r = c.second;
		const ld x = c.first;
		if (r > amid) {
			ld dis = sqrt(r*r - amid*amid);
			mp[x - dis]++;
			mp[x + dis]--;
		}
	}
	ld pre = -1;
	int num = 0;
	ld len = 0;
	bool preok = false;
	for (auto m : mp) {
		num += m.second;
		if (num) {
			if (!preok) {
				pre = m.first;
			}
		}
		else {
			if (num < 0)assert(false);
			if (preok) {
				len = max(len, m.first - pre);
			}
		}
		preok = num;
	}
	return amid*2 < len;
}
int main() { 
	while (1) {
		cin >> N;
		if (!N)break;
		vector<pair<ld, ld>>cs;
		for (int i = 0; i < N; ++i) {
			int x, r; cin >> x >> r;
			cs.push_back(make_pair(x, r));
		}
		ld amin = 0;
		ld amax = 2e6;
		int atime = 40;
		while (atime--) {
			ld amid = (amin + amax) / 2;
			if (check(cs, amid)) {
				amin = amid;
			}
			else {
				amax = amid;
			}
		}
		cout << setprecision(22) << fixed << amin*2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 12420
import java.io.*;
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int a,b;
        int s,l;
        try{
        line = reader.readLine();
        String[] x = line.split(" ");
        a = Integer.parseInt(x[0]);
        b = Integer.parseInt(x[1]);
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
        }catch (NumberFormatException e) {
            System.out.println(e);
        } catch (IOException e) {
            System.out.println(e);
        }

    
    }
}



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

pair<int,int> p[100001];

int main() {

    int n;

    long long int k;

    cin >> n >> k;

    for(int i=0; i<n; i++){
        cin >> p[i].first >> p[i].second;
    }

    sort(p,p+n);

    long long int counter = 0;

    for(int i=0; i<n; i++){
        counter += p[i].second;
        if(counter >= k){
            cout << p[i].first << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    int ans = INF;
    int n = s.size();
    int m = t.size();
    rep(i, 0, n - m + 1) {
        string sub = s.substr(i, m);
        int cnt = 0;
        rep(j, 0, m) {
            if (sub[j] != t[j]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#pragma warning (disable :4996)
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-12;
#define For(i,n,m) for(int i=n;i<=m;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,l,r) for(int i=l;i>=r;--i)
#define clr(a,b) memset(a,b,sizeof(a))

int n, k;
int mp[110];
int cnt(0);
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> k;
	rep(i, 1, k) {
		int d, a;
		cin >> d;
		rep(j, 1, d) {
			cin >> a;
			mp[a] = 1;
		}

	}
	rep(i, 1, n) if (!mp[i]) ++cnt;
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
    string u,s,t;
    cin>>u;
    for(int i=u.size()-1;i>=0;i--)s+=u[i];
    rep(i,s.size()){
      if(s[i]=='m'){
        t+="maerd";
        i+=4;
      }else if(s[i]=='e'){
        t+="esare";
        i+=4;
      }else if(s[i]=='r'){
        if(s[i+2]=='m'){
          t+="remaerd";
          i+=6;
        }else if(s[i+2]=='s'){
          t+="resare";
          i+=5;
        }
      }
    }

    cout<<(s==t?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		vector<vint> table(9, vint(9));
		
		rep(y, 9) rep(x, 9)
		{
			cin >> table[y][x];
			table[y][x]--;
		}
		
		vector<bitset<9> > flags(9);
		
		// ツ行
		rep(y, 9) 
		{
			vint v(9, 0);
			rep(x, 9)
			{
				v[table[y][x]]++;
			}
			
			rep(x, 9)
			{
				flags[y][x] = 1 < v[table[y][x]];
			}
		}
		
		// ツ療ア
		rep(x, 9) 
		{
			vint v(9, 0);
			rep(y, 9)
			{
				v[table[y][x]]++;
			}
			
			rep(y, 9)
			{
				flags[y][x] = flags[y][x] || 1 < v[table[y][x]];
			}
		}
		
		
		// square
		rep(y, 3) rep(x, 3) 
		{
			vint v(9, 0);
			rep(yy, 3) rep(xx, 3)
			{
				v[table[y * 3 + yy][x * 3 + xx]]++;
			}
			
			rep(yy, 3) rep(xx, 3)
			{
				flags[y * 3 + yy][x * 3 + xx] = flags[y * 3 + yy][x * 3 + xx] || 1 < v[table[y * 3 + yy][x * 3 + xx]];
			}
		}
		
		
		// print
		rep(y, 9) rep(x, 9)
			cout << (flags[y][x] ? "*" : " ") << table[y][x] + 1 << (x == 8 ? "\n" : "");
		
		if(n) cout << endl;
			
	}
}

Measured memory_bytes: 0