akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s;
  int ans=700;
  cin>>s;
  rep(i,0,3)if(s[i]=='o')ans+=100;
  cout<<ans<<endl;
}

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

int main() {
    double d,t,s;
    std::cin >> d>>t>>s;
    if(d/s <= t){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;
  cin>>n;
  int res=1000*1000*1000;
  while(n--){
    int a;cin>>a;
    int t=0;
    while(a%2==0){
      a/=2;
      t++;
    }
    res=min(t, res);
  }
  cout<<res<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	string str;
	cin >> n >> k;
	cin >> str;
	str[k - 1] = tolower(str[k - 1]);
	cout << str << endl;
	return 0;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

ll pCount(int x){
  if(x==0) return 1;
  return pCount(x-1)*2 + 1;
}

ll allCount(int x){
  if(x==0) return 1;
  return allCount(x-1)*2 + 3;
}


signed main() {
  int h,w;
  cin >> h >> w;
  
  vector< vector<int> > a(h,vector<int>(w));
  
  for(int y=0;y<h;y++){
    for(int x=0;x<w;x++){
      cin >> a[y][x];
    }
  }
  
  int count = 0;
  vector<string> outStrV;
  for(int y=0;y<h;y++){
    for(int x=0;x<w;x++){
      if(a[y][x]%2==1){
        if(x<w-1){
          outStrV.push_back(
          	to_string(y+1) + " " + to_string(x+1) 
            + " " + to_string(y+1) + " " + to_string(x+2) );
          a[y][x]--;a[y][x+1]++;
        }
        else if(y<h-1){
          outStrV.push_back(
          	to_string(y+1) + " " + to_string(x+1) 
            + " " + to_string(y+2) + " " + to_string(x+1) );
          a[y][x]--;a[y+1][x]++;
        }
      }
    }
  }

  cout << outStrV.size() << endl;
  for(auto s:outStrV){
    cout << s << endl;
  }
  
  return 0;
}



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

using namespace std;

int main() {
    string s;
    cin >> s;

    int res = 0;
    for (int i = 0; i < static_cast<int>(s.size()) / 2; i++) {
        if (s[i] != s[s.size() - i - 1]) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=2e5+10;
int n,a[N],sum;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i],sum^=a[i];
	for(int i=1;i<=n;i++)	cout<<(a[i]^sum)<<' ';
	return 0;
}


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

using namespace std;

#define endl '\n'

typedef long long ll;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

#define _rep3(i,p,n) for(int i=(p),i##_counter=(n); i<i##_counter;++i)
#define _rep2(i,n,_) _rep3(i,0,n)
#define _rep_call(a, b, c, name, ...) name(a, b, c)
#define rep(...) _rep_call(__VA_ARGS__, _rep3, _rep2)

#define dump(x)  cerr << #x << " = " << (x) << '\n'
#define debug(x) cerr << #x << " = " << (x) << " (at line " << __LINE__ << ")" << " " << __FILE__ << '\n'

bool check(const set<int> &d, int i) {
    while (i) {
        if (d.find(i % 10) != d.end()) return false;
        i /= 10;
    }
    return true;
}

void Main() {
    int N, K; cin >> N >> K;
    set<int> d;
    rep(i, K) {
        int dd; cin >> dd;
        d.insert(dd);
    }
    rep(i, N, 1000000) {
        if (check(d, i)) {
            cout << i << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 256
while True:
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    else:
        for i in range(h):
            if i == 0 or i== h-1:
                print('#'*w)
            else:
                print('#'+'.'*(w-2)+'#')
    print('')


Measured memory_bytes: 5612
N = int(input())
v = list(map(int, input().split()))

def nabe(x,y):
    return (x + y) / 2

#for i in range(N - 1):
v = sorted(v)
for _ in range(N - 1):
    x = v.pop(0)
    y = v.pop(0)

    v.insert(0, nabe(x,y))

print(v[0])

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            Pt a = new Pt(input[0], input[1]);
            Pt b = new Pt(input[2], input[3]);

            Seg s = new Seg(a, b);

            int q = int.Parse(Console.ReadLine());

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < q; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
                Pt p = new Pt(input[0], input[1]);

                sb.AppendLine(Project(s, p).ToString());
            }
            Console.Write(sb);
        }

        static Pt Project(Seg s, Pt p)
        {
            Pt b = s.p2 - s.p1;
            double r = (p - s.p1).Dot(b) / b.Norm;
            return s.p1 + b * r;
        }
    }

    struct Pt : IComparable<Pt>
    {
        static readonly double EPS = 1E-10;

        internal double x, y;

        public Pt(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public double Abs { get { return Math.Sqrt(Norm); } }
        public double Norm { get { return x * x + y * y; } }

        public double Dot(Pt p) { return x * p.x + y * p.y; }
        public double Cross(Pt p) { return x * p.y - y * p.x; }

        public static Pt operator +(Pt a, Pt b) { return new Pt(a.x + b.x, a.y + b.y); }
        public static Pt operator -(Pt a, Pt b) { return new Pt(a.x - b.x, a.y - b.y); }
        public static Pt operator *(Pt p, double d) { return new Pt(p.x * d, p.y * d); }
        public static Pt operator /(Pt p, double d) { return new Pt(p.x / d, p.y / d); }
        public static bool operator <(Pt a, Pt b) { return Math.Abs(a.x - b.x) > EPS ? a.x < b.x : a.y < b.y; }
        public static bool operator >(Pt a, Pt b) { return Math.Abs(a.x - b.x) > EPS ? a.x > b.x : a.y > b.y; }
        public static bool operator ==(Pt a, Pt b) { return Math.Abs(a.x - b.x) < EPS && Math.Abs(a.y - b.y) < EPS; }
        public static bool operator !=(Pt a, Pt b) { return Math.Abs(a.x - b.x) >= EPS || Math.Abs(a.y - b.y) >= EPS; }

        public int CompareTo(Pt other)
        {
            return x != other.x ? (int)(x - other.x) : (int)(y - other.y);
        }

        public override bool Equals(object obj)
        {
            Pt other = (Pt)obj;
            return Math.Abs(x - other.x) < EPS && Math.Abs(y - other.y) < EPS;
        }

        public override int GetHashCode()
        {
            return x.GetHashCode() ^ y.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("{0:f10} {1:f10}", x, y);
        }
    }

    struct Seg
    {
        internal Pt p1, p2;

        public Seg(Pt a, Pt b)
        {
            p1 = a;
            p2 = b;
        }
    }
}

Measured memory_bytes: 9672
a = [0, 0, 1, 1] + [0, 1] * 25009
for i in range(3, 50022, 2):
    if a[i]:
        for j in range(2, 50021 // i + 1):a[i * j] = 0
while 1:
    try:
        n = int(input())
        print("{} {}".format(n - 1 - a[:n][::-1].index(1), n + 1 + a[n + 1:].index(1)))
    except:break


Measured memory_bytes: 6692
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define eps 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
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<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



ll N, K;
ll a[1100];
ll b[1100];
ll c[1100];
ll num[50];

int main () {
  cin >> N >> K;
  ll sum = 0;
  rep(i, N) {
    ll tmp;
    cin >> tmp;
    a[i] = tmp;
    sum += tmp;
  }

  rep(i, N) {
    b[i] = b[i-1] + a[i];
  }
  for (int i=N;i>=1;--i) {
    c[i] = c[i+1] + a[i];
  }

  vector<ll> v;

  for (int k=0;k<N;++k) {
    for (int l=N+1;l>k+1;--l) {
      v.push_back(sum-b[k]-c[l]);
    }
  }

  //printv(v);

  int n = v.size();
  vector<bool> ok;
  ok.assign(n, true);

  //for (auto p: mp) {
  //  cout << p.first << " " << p.second << "\n";
  //}

  ll ans = 0;

  for (ll s=60;s>=0;--s) {
    int ct = 0;

    Rep(i, n) {
      bitset<59> bt(v[i]);

      if (bt[s] && ok[i]) {
        ct++;
      } 
    }

    if (ct >= K) {
      ans += (1LL << s);

      Rep(i, n) {
        bitset<59> bt(v[i]);
        if (!bt[s] && ok[i]) ok[i] = false;
      }
    }
  }

  cout << ans << "\n";

}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int sum(int x) {
  int s = 0;
  while (x) {
    int d = x % 10;
    x /= 10;
    s += d;
  }

  return s;
}

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

  int ans = n;
  for (int a = 1; a < n; ++a) {
    int b = n - a;
    int cnt = sum(a) + sum(b);
    ans = min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;
 
int main()
{
  int n;
  cin >> n;
  int k;
  bool win = false;
  while (n--)
  {
    cin >> k;
    if (k%2==1)
    {
      win = true;
      break;
    }
  }
  if (win) cout << "first";
  else cout << "second";
  return 0;
}

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


int main() {

    int N;
    cin >> N;

    map<string, int> memo;

    for( int i = 0; i < N; i++){
        string s;
        cin >> s;

        memo[s] += 1;
    }

    int maxv =0;
    for (auto x : memo ){
        int v = x.second;
        if (v > maxv) maxv = v;
    }

    for (auto x : memo ){
        if( x.second == maxv){
            cout << x.first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 25216
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a, b = inpm()
ans = -1
if(a < 10 and b < 10):
    ans = a * b
print(ans)




Measured memory_bytes: 74884
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define int long long
    # define mo 1000000007
    using namespace std;
    #define goku ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    signed main(){
        goku
      int n,m,su=0;
      cin>>n>>m;
     int a[m];
     for(int i=0;i<m;i++)
     {
         cin>>a[i];
         su+=a[i];
     }
     if(su>=n)
        cout<<"Yes";
     else
        cout<<"No";
       return 0;
    }


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static int N;
    static long[] Al, Bl;

    static long Dfs(int i, long sum)
    {
        if (i == N) return sum;

        var p1 = (Al[i] > Bl[i]) ? Bl[i] : Al[i];
        sum += p1;
        Bl[i] -= p1;
        var p2 = (Al[i + 1] > Bl[i]) ? Bl[i] : Al[i + 1];
        sum += p2;
        Al[i + 1] -= p2;
        sum = Dfs(i + 1, sum);
        return sum;
    }

    static void Main(string[] args)
    {
        N = int.Parse(Console.ReadLine());
        Al = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        Bl = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        Console.WriteLine(Dfs(0, 0));
    }
}


Measured memory_bytes: 42456
#include <iostream>
using namespace std;
int main(void){
    int n, sum_t=0;
    cin>>n;
    string s[n], x;
    int t[n];
    bool flag = false;
    
    for(int i=0; i<n; i++)
        cin>>s[i]>>t[i];
    
    cin>>x;
    
    for(int i=0; i<n; i++){
        if (flag)
            sum_t += t[i];
        else if(s[i] == x)
            flag = true;
    }
    cout<<sum_t<<endl;
}


Measured memory_bytes: 256
def main() :
    n = int(input())
    nums = [int(i) for i in input().split()]
    exchange_count = 0

    for i in range(n) :
        minj = i
        for j in range(i, n) :
            if nums[j] < nums[minj] :
                minj = j
        if minj != i :
                exchange_count += 1
        nums[i], nums[minj] = nums[minj], nums[i]

    print(" ".join(map(str, nums)))
    print(exchange_count)

if __name__ == '__main__' :
    main()

Measured memory_bytes: 7744
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;
 
using namespace std;
 
signed main(){
  int a, b, n;
  cin >> n >> a >> b;
  bool flag = true;
  for(int i = 1;i < 100000; i++){
    int num = n * i;
    if(a <= num && num <= b){
     cout << "OK" << endl;
      return 0;
    }
    else if(num > b){
      cout << "NG" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3636
import sys
import bisect
N, K = map(int, sys.stdin.readline().split())
V = list(map(int, sys.stdin.readline().split()))

ans = 0

max_take = min(N, K)

for A in range(max_take + 1):
    for B in range(max_take - A + 1):
        #if A > 0 and B > 0:
        list = V[:A] + V[N - B:]
        total_sum = sum(list) 
        list.sort()
        n = bisect.bisect_left(list, 0)
        if n <= K - (A + B):
            total_sum -= sum(list[:n])
        else:
            total_sum -= sum(list[:K - (A + B)])
        '''
        elif A == 0 and B > 0:
            list = V[N - B:]
            total_sum = sum(list)
            list.sort()
            n = bisect.bisect_left(list, 0)
            if n <= K - (A + B):
                total_sum -= sum(list[:n])
            else:
                total_sum -= sum(list[:K - (A + B)])
        elif A > 0 and B == 0:
            list = V[:A]
            total_sum = sum(list)
            list.sort()
            n = bisect.bisect_left(list, 0)
            if n <= K - (A + B):
                total_sum -= sum(list[:n])
            else:
                total_sum -= sum(list[:K - (A + B)])
        else:
            continue'''
        
        if total_sum > ans:
            ans = total_sum
            
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
bool lkado(vector<string> &v, int i, int j) {
  char c = v[i+1][j];
  return c != v[i][j] && c != v[i][j+1] && c != v[i+1][j+1];
}
bool rkado(vector<string> &v, int i, int j) {
  char c = v[i][j+1];
  return c != v[i][j] && c != v[i+1][j] && c != v[i+1][j+1];
}
bool inkado(vector<string> &v, int i, int j) {
  return v[i][j] == '.' && v[i][j] == '#';
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int h, w; cin >> h >> w;
  vector<string> v(h);
  for(int i=0;i<(h);++i) {
    cin >> v[i];
  }
  reverse((v).begin(),(v).end());
  vvi kado(h-1, vi (w-1, -1));
  for(int i=0;i<(h-1);++i) {
    for(int j=0;j<(w-1);++j) {
      if(lkado(v, i, j)) {
        kado[i][j] = 0;
      } else if(rkado(v, i, j)) {
        kado[i][j] = 1;
      } else if(inkado(v, i, j)) {
        kado[i][j] = 2;
      }
    }
  }
  int ma = 0;
  for(int i=0;i<(h);++i) {
    for(int j=0;j<(w);++j) {
      if(i != h-1 && j != w-1 && kado[i][j] == -1) continue;
      int l = 0, r = 0;
      int g = __gcd(i+1, j+1);
      int tmpi = (i+1)/g, tmpj = (j+1)/g;
      for(int k=0;k<(h-1);++k) {
        if((k+1) % tmpi == 0) {
          int idx = (k+1)*tmpj/tmpi-1;
          if(idx >= w-1) continue;
          int nowkado = kado[k][idx];
          if(nowkado == 0) {
            l++;
          } else if(nowkado == 1) {
            r++;
          } else if(nowkado == 2) {
            l++;
            r++;
          }
        } else {
          double tmp = (double)(k+1) * tmpj / tmpi;
          int idx = floor(tmp);
          if(idx >= w) continue;
          if(v[k][idx] == '.' && v[k+1][idx] == '#') {
            l++;
            r++;
          }
        }
      }
      for(int k=0;k<(w-1);++k) {
        if((k+1)%tmpj) {
          double tmp = (double)(k+1) * tmpi / tmpj;
          int idx = floor(tmp);
          if(idx >= h) continue;
          if(v[idx][k] == '.' && v[idx][k+1] == '#') {
            l++;
            r++;
          }
        }
      }
      chmax(ma, l);
      chmax(ma, r);
    }
  }
  cout << (ma + 1 + (v[0][0] == '#')) << endl;
}



Measured memory_bytes: 4688
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin>>a;
    if(a==2){
        cout<<"No";
        return 0;
    }
    cin>>a;
    if(a==2){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

int main() {
	int cnt , mochi[200] , tmp;
	cin >> cnt;
	for(int i = 0; i <cnt ;i++){
		cin >> mochi[i];
	}
	for(int i = 1;i <= cnt;i++){
		for(int j = 0;j < cnt - i;j++){
			if(mochi[j] > mochi[j + 1]){
				tmp = mochi[j + 1];
				mochi[j + 1] = mochi[j];
				mochi[j] = tmp;
			}
		}
	}
	tmp = 0;
	int jud = 0;
	for(int i = 0; i < cnt;i++){
	            if(tmp < mochi[i]) jud++;
	            tmp = mochi[i];
	}
	cout << jud;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

vint edge[100010];
// 0→1,2に色を塗っていく
int color[100010];

bool dfs(int pos) {
	bool ok = true;
	rep(i, edge[pos].size()) {
		int to = edge[pos][i];
		if (color[to] == 0) {
			color[to] = 1 + (2 - color[pos]);
			if (!dfs(to))	ok = false;
		}
		else if (color[to] == color[pos])	ok = false;
	}
	return ok;
}

int main() {
	int n, m;	cin >> n >> m;
	rep(i, m) {
		int a, b;	cin >> a >> b;	a--;	b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	color[0] = 1;
	if (dfs(0)) {
		ll white = 0, black = 0;
		rep(i, n) {
			if (color[i] == 1)	white++;
			else	black++;
		}
		cout << black * white - m << endl;
	}
	else {
		cout << (ll)n*(n - 1) / 2 - m << endl;
	}
}

Measured memory_bytes: 7296
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


Measured memory_bytes: 20536
fun main(args: Array<String>) {
    val S = next().map { it - 'a' }
    val T = next().map { it - 'a' }
    val sa = IntArray(26) { -1 }
    val ta = IntArray(26) { -1 }
    for (n in 0 until S.size) {
        if (sa[S[n]] == -1) sa[S[n]] = T[n]
        else if (sa[S[n]] != T[n]) {
            println("No"); return
        }
        if (ta[T[n]] == -1) ta[T[n]] = S[n]
        else if (ta[T[n]] != S[n]) {
            println("No"); return
        }
    }
    println("Yes")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 37800
#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
	constexpr u64 &value() noexcept { return a; }
	constexpr const u64 &value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint &operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint &operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint &operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};

#include <algorithm>
#include <iostream>
#include <vector>

int main() {
	using mint = modint<1000000007>;

	int n, x;
	std::cin >> n >> x;
	std::vector<int> s(n);
	for (auto &e : s) {
		std::cin >> e;
	}
	std::sort(s.begin(), s.end());

	std::vector<std::vector<mint>> dp(n + 1, std::vector<mint>(x + 1));

	for (int i = 0; i <= x; ++i) {
		dp[0][i] = i;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= x; ++j) {
			dp[i + 1][j] = dp[i][j] * i + dp[i][j % s[i]];
		}
	}

	std::cout << dp[n][x].value() << std::endl;

	return 0;
}


Measured memory_bytes: 158592
from collections import deque
n, m = map(int, input().split())
p = list(map(int, input().split()))
par = list(range(n+1))

def find(x):
    p_ = par[x]
    if p_ == x:
        return x
    a = find(p_)
    par[x] = a
    return a

for _ in range(m):
    x, y = map(int, input().split())
    bx, by = find(x), find(y)
    par[y] = bx
    par[by] = bx

ans = 0
for i in range(1, n+1):
    if find(i) == find(p[i-1]):
        ans += 1
print(ans)


Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int modPow(ll a, ll n, ll p) {
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	ll t = modPow(a, n / 2, p);
	return (t * t) % p;
}

int main() {
	ll n;
	cin >> n;
	ll a, b;
	cin >> a >> b;
	ll p = 1e9 + 7;
	ll temp = modPow((ll)2, n, p)-1;
	ll atemp = 1, atemp2 = 1;
	ll btemp = 1, btemp2 = 1;
	rep(i,a) {
		atemp = atemp * (n-i) % p;
	}
	for(int i=1; i<=a; i++) {
		atemp2 *= modPow(i, p-2, p);
		atemp2 %= p;
	}
	atemp = atemp * atemp2 % p;
	rep(i,b) {
		btemp = btemp * (n-i) % p;
	}
	for(int i=1; i<=b; i++) {
		btemp2 *= modPow(i, p-2, p);
		btemp2 %= p;
	}
	btemp = btemp * btemp2 % p;
	temp = temp - atemp - btemp;
	temp %= p;
	while(temp < 0) {
		temp += p;
	}
	cout << temp << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		mms(ar,a)       memset(ar,a,sizeof(ar))
#define		ss              ' '
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define		OO              10000000000

int main(){
//    freopen("input.txt","r",stdin);
    ll a,b,c=0,i,j,t,k,lie,m,n,o,x,y,z,ar[200010];
    string s,s2,st,st2;
    cin>>s;
    s2=s;
    st.assign(s,0,zz(s)/2);
    st2=st;
    reverse(all(s2));
    reverse(all(st2));
    if(s==s2 and st==st2) printf("Yes\n");
    else  printf("No\n");

    return 0;
}


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

int main(){
    int n; string s, t; cin >> n >> s;
    int rc = 0, lc = 0;
    for (auto i = 0; i < n; i++) {
        if(s[i] == '(') rc++;
        else {
            if(rc == 0) lc++;
            else rc--;
        }
    }

    for (auto i = 0; i < lc; i++) t += "(";
    t += s;
    for (auto i = 0; i < rc; i++) t += ")";

    cout << t << endl;
    return 0;
}

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

int main(){
    long long A, B, C;
    cin >> A >> B >> C;
    vector<long long> vals{A, B, C};
    sort(vals.begin(), vals.end());

    long long max_val = vals[2];
    long long ans = 0;
    if(max_val%2 == 1){
        ans = vals[0]*vals[1];
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3636
#include<stdio.h>
int srx,sry,n;
int main()
{
  scanf("%d%d",&srx,&sry);
  if(srx==1&&sry==2||srx==2&&sry==1)
  printf("3");
  else if(srx==1&&sry==3||srx==3&&sry==1)
  printf("2");  
  else if(srx==2&&sry==3||srx==3&&sry==2)
  printf("1");  
  return 0;
}

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

int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y; 
  
  if (n <= k) cout << x * n << endl;
  else cout << x * k + y *(n - k) << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

int n;

/* add your algorithm here */

int main() {
  cin >> n;
  vector<int> s(n,0);
  int sum = 0;
  rep(i,n) {
    cin >> s[i];
    sum += s[i];
  }

  if (sum % 10 != 0) {
    cout << sum << endl;
  } else {
    int t = 101;
    for (auto itr : s) {
      if (itr % 10 != 0) {
        t = min(t,itr);
      }
    }
    if (t == 101) sum = 0;
    else sum -= t;
    cout << sum << endl;
  }
}


Measured memory_bytes: 256
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Wednesday August 19, 2020
 */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof(arr))
#define finally(value) {cout << value << '\n'; return;}
#define ll    int64_t
 
const int oo = int(1e9);
const ll lloo  = (ll)(1e18);
const int N_MAX = int(3001);
 
class Task {
public:
    int N;
    vector<int> A;
 
    ll dp[N_MAX][N_MAX];
 
    ll go(int l, int r, bool player) {
        if(l > r || l > N || r < 0) return 0LL;
        ll &ans = dp[l][r];
        if(ans != -1LL) return ans;
        ll sign = player?1LL:-1LL;
        ll first = A[l]*sign + go(l+1, r, !player);
        ll second = A[r]*sign + go(l, r-1, !player);
        ans = 0;
        if(player) ans = max(first, second);
        else ans = min(first, second);
        return ans;
    }
 
    void solveOne(istream &in, ostream &out) {
        in >> N;
        A.resize(N+1);
        for(int i = 1; i <= N; ++i){
            in >> A[i];
        }
        ms(dp, -1LL);
        ll ans = go(1, N, true);
        finally(ans);
    }
    
    void solve(istream &in, ostream &out) {
        int t=1;
        while(t--) solveOne(in, out);
    }
};
 
auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 74256
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
  ll n,m,k;
  cin>>n>>m>>k;
  ve a,b;
  for (int i = 0; i < n; ++i)
  {
    ll yo;
    cin>>yo;
    a.pb(yo);
  }
  for (int i = 0; i < m; ++i)
  {
    ll yo;
    cin>>yo;
    b.pb(yo);
  }
  for (int i = 1; i < n; ++i)
  {
    a[i]+=a[i-1];
  }
  for (int i = 1; i < m; ++i)
  {
    b[i]+=b[i-1];
  }
  ll ans=0;
  for (int i = 0; i < n; ++i)
  {
    ll cur=0;
    if(a[i]<=k){
      int low=0,high=m-1;
      ll sol=-1;
      while(high>=low){
        int med=(low+high)/2;
        if(a[i]+b[med]<=k){
          sol=med;
          low=med+1;
        }
        else high=med-1;
      }
      if(sol!=-1){
        ans=max(ans,i+sol+2);
      }
      else ans=max(ans,(ll)(i+1));
    }
    else break;
  }
  for (int i = 0; i < m; ++i)
  {
    ll cur=0;
    if(b[i]<=k){
      int low=0,high=n-1;
      ll sol=-1;
      while(high>=low){
        int med=(low+high)/2;
        if(b[i]+a[med]<=k){
          sol=med;
          low=med+1;
        }
        else high=med-1;
      }
      if(sol!=-1){
        ans=max(ans,i+sol+2);
      }
      else ans=max(ans,(ll)(i+1));
    }
    else break;
  }
  cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 7968
fun main(args:Array<String>){
  var (n,x) = readLine()!!.split(" ").map(String::toInt)
  var l = readLine()!!.split(" ").map{it.toInt()}
  var m = 0
  var count = 1    
  for(i in 0..n-1){
    m += l[i]
    if(m>x)break
    count++  
  }
  println(count)
}

Measured memory_bytes: 37928
object Main extends App {
  var input = readLine
  val Evens = input.split(" ")(0).toInt - 1
  val Odds  = input.split(" ")(1).toInt - 1
  
  var count = 0
  
  for(i <- 0 to Evens) {
    count = count + i
  }
  
  for(j <- 0 to Odds) {
    count = count + j
  }
  
  println(count)
  
}

Measured memory_bytes: 25420
### constant

MAX_INT = (1 << 31) - 1

### main

while true
  c, n, m, sn, dn = gets.strip.split(' ').map{|s| s.to_i}
  break if c + n + m + sn + dn == 0

  sn -= 1
  dn -= 1

  edges = n.times.map{[]}
  nbrs = n.times.map{[]}

  m.times.each do
    a, b, f = gets.strip.split(' ').map{|s| s.to_i}
    a -= 1
    b -= 1

    edges[a][b] = edges[b][a] = f
    nbrs[a] << b
    nbrs[b] << a
  end

  dists = n.times.map{[MAX_INT] * (c + 1)}
  dists[sn][c] = 0
  visited = n.times.map{[false] * (c + 1)}
  visited[sn][c] = true
  q = [[sn, c]]

  while ! q.empty?
    nd0, c0 = q.shift
    next if nd0 == dn

    for nd1 in nbrs[nd0]
      e = edges[nd0][nd1]
      he = e / 2
      if dists[nd1][c0] > dists[nd0][c0] + e
        dists[nd1][c0] = dists[nd0][c0] + e
        q << [nd1, c0]
      end
      if c0 > 0 && dists[nd1][c0 - 1] > dists[nd0][c0] + he
        dists[nd1][c0 - 1] = dists[nd0][c0] + he
        q << [nd1, c0 - 1]
      end
    end
  end

  puts dists[dn].min
end

Measured memory_bytes: 6240
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;
 
/** Template Begins **/
#define int ll 
typedef long long        ll;
typedef pair<int,int>    PII;
 
#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)
 
/* Debug */
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
 
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
/* Debug Ends */
 
const int N = 1e5+7;
 
/** Template Ends **/
int n, m, k;
double x[N], d[N];
int p[N];
bool vis[N];
int df[N];

signed main() {
 
    IOS;
    cout << fixed << setprecision(15);
    cin >> n;
    FOR(i,1,n) cin >> x[i];
    FOR(i,1,n-1) d[i] = x[i + 1] - x[i];
    FOR(i,1,n) p[i] = i;

    cin >> m >> k;
    LP(i,m) {
        int x; cin >> x;
        swap(p[x], p[x - 1]);
    }

    FOR(i,1,n-1) {
        vector<int> cyc;
        int cur = i;
        while (!vis[cur]) {
            cyc.pb(cur);
            vis[cur] = 1;
            cur = p[cur];
        }
        for (int j = 0; j < cyc.size(); j++) {
            int p = cyc[j];
            int q = cyc[(j + k) % cyc.size()];
            df[cyc[j]] = d[cyc[(j + k) % cyc.size()]]; 
        }
    }
    cout << x[1] << endl;
    FOR(i,2,n) {
        x[i] = x[i - 1] + df[i - 1];
        cout << x[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 7452
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  if (tail + 1 == LEN){
    tail = 0;
  }
  else{
    tail = tail + 1;
  }  
}

P dequeue(){
  P tmp = Q[head];
  if (head + 1 == LEN){
    head = 0;
  }
  else{
    head = head + 1;
  }
  return tmp;
}


int main(){
  int elaps = 0, c;
  int i, q, total = 0;
  P u;
  scanf("%d %d", &n, &q);  
  for ( i = 1; i <= n; i++){    
    scanf("%s", u.name);
    scanf("%d", &u.t);
    enqueue(u);
  }
  
  while(n>0){
    u = dequeue();
    if (u.t <= q){
      elaps += u.t;
      printf("%s %d\n", u.name, elaps);
      n--;
    }    
    else if(u.t>q){
      u.t -= q;
      elaps += q;
      enqueue(u);
    }   
  } 
  return 0;
}

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

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int A, B, C, D, E, F;

int main(){
    cin >> A >> B >> C >> D >> E >> F;
    
    vector<bool> x(F + 1), y(F + 1);
    rep(i, F + 1) {
        rep(j, F + 1) {
            if (100 * A * i + 100 * B * j <= F) x[100 * A * i + 100 * B * j] = true;
        }
    }

    rep(i, F + 1) {
        rep(j, F + 1) {
            if (C * i + D * j <= F) y[C * i + D * j] = true;
        }
    }
    
    int w = A * 100, s = 0;
    rep(i, F + 1) {
        rep(j, F + 1) {
            if (!x[i] || !y[j]) continue;
            if (F < i + j) continue;
            if (E * i >= j * 100) {
                if ((double)s / (w + s) < (double)j / (i + j)) {
                    w = i, s = j;
                }
            }
        }
    }

    cout << (w + s) << " " << s << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int  main(){
        long long  n, w; cin>>n>>w;
        long long wt[10000],val[10000];
        for(int i=0;i<n;i++)cin>>wt[i]>>val[i];
        long long  dp[n+1][w+1];
        memset(dp, 0, sizeof(dp));
        for(int i=1; i<n+1; i++){
        	for(int j=0; j<w+1; j++){
        		if(j>=wt[i-1])dp[i][j]=max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
        		else dp[i][j]=dp[i-1][j];
        	}
        }
        cout<<dp[n][w]<<endl;   
}

Measured memory_bytes: 82324
#include<iostream>
#include<string>
using namespace std;
string S;
int main(){
	cin>>S;int cnt=0,t=S.size();
	for(int i=0;i<S.size();i++){
		if(S[i]=='S')cnt++;
		if(S[i]=='T'){
			if(cnt>=1){t-=2;cnt--;}
		}
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 640
# @author 

import sys

class CBuildStairs:
    def solve(self):
        n = int(input())
        h = [int(_) for _ in input().split()]
        for i in range(1, n):
            if h[i] < h[i - 1]:
                print("No")
                break
            elif h[i] > h[i - 1]:
                h[i] -= 1
        else:
            print("Yes")

solver = CBuildStairs()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 59632
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	a := getNextInt(scanner)
	b := getNextInt(scanner)
	c := getNextInt(scanner)
	d := getNextInt(scanner)
	e := getNextInt(scanner)
	f := getNextInt(scanner)

	max := 0.0

	ans1 := 0
	ans2 := 0
	for i := 0; i*a*100 <= f; i++ {
		w1 := i * a * 100
		for ii := 0; w1+ii*b*100 <= f; ii++ {
			w2 := ii * b * 100
			for iii := 0; w1+w2+iii*c <= f; iii++ {
				s1 := iii * c
				for iiii := 0; w1+w2+s1+iiii*d <= f; iiii++ {
					s2 := iiii * d
					if (s1+s2)*100 > (w1+w2)*e {
						break
					}
					n := float64(s1+s2) / float64(w1+w2+s1+s2)
					if max <= n {
						max = n
						ans1 = w1 + w2 + s1 + s2
						ans2 = s1 + s2
					}
				}
			}
		}
	}

	fmt.Fprintln(writer, fmt.Sprintf("%d %d", ans1, ans2))

	writer.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,kekka = 0,a;
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>a;
		if(a == 2){
			continue;
		}
		else if(a%2 == 0){
			kekka++;
			continue;
			
		}
		int eziri = sqrt(a)+1;
		for(int j = 2;j<eziri;j++){
			if(a%j == 0){
				kekka++;
				break;
			}
		}
	}
	cout<<n-kekka<<endl;
	return 0;
}


Measured memory_bytes: 3100