akhauriyash/Code-Regression huggingface dataset:
s = input()
slist = list(s)
slen = len(slist)
res = [-1,-1]
for i in range(slen):
    if i + 1 <= slen - 1:
        if slist[i] == slist[i+1]:
            res = [i+1,i+2]
            break
    if i + 2 <= slen - 1:
        if slist[i] == slist[i+2]:
            res = [i+1,i+3]
            break
print(res[0],res[1])

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

using namespace std;

const int N = 405;
const long long INF = 1e15;
long long n, a[N], cost[N][N], prefix[N];

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

	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		prefix[i] = prefix[i - 1] + a[i];
	}

	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j){
			cost[i][j] = INF;
			if(i == j)cost[i][j] = 0;
		}

	for(int len = 2;len<=n;++len)
		for(int i=1;i + len - 1<=n;++i){
			int j = i + len - 1;
			if(len == 2){
				cost[i][j] = a[i] + a[j];
				continue;
			}

			for(int k=i;k<= j - 1;++k)
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k + 1][j]);
			cost[i][j] += prefix[j] - prefix[i - 1];
		}
	cout<<cost[1][n]<<"\n";
	return 0;
}

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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
const int mod = (int)1e9 + 7;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;

    int a[n];
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }

    sort(a, a + n);

    int alice = 0, bob = 0;
    for(int i = n - 1; i >= 0; --i){
        if((i & 1) == (n & 1)) bob += a[i];
        else alice += a[i];
    }

    cout << alice - bob << endl;
    
    return 0;
}

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

struct S
{
    int a, b;
};

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<S> store(N);

    for (int i = 0; i < N; i++)
    {
        std::cin >> store[i].a >> store[i].b;
    }

    std::sort(store.begin(), store.end(), [](S a, S b) { return a.a < b.a; });

    int cnt = 0;
    long long ans = 0;
    for (int i = 0; i < N; i++)
    {
        int k = std::min(store[i].b, (M - cnt));
        ans += ((long long)k * store[i].a);
        cnt += k;
        if (cnt >= M)break;
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    ll cnt = 1;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == cnt){
            cnt++;
        }else{
            ans++;
        }
    }

    if(ans==n){
        cout << -1 << endl;
    }else{
    cout << ans << endl;

    }
    return 0;

}


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

int main() {
  int N;
  cin >> N;
  int A = 0;  //Aの得点
  int B = 0;  //Bの得点
  
  //カードの配列を作る
  vector<int> card(N);
  for (int i = 0; i < N; i++) {
    cin >> card.at(i);
  }
  
  //配列を大きい順にソート
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  //Aから順におっきいほうからとっていく
  for (int i = 0; i < N; i += 2) {
    int add = card.at(i);
    A += add;
  }
  
  //Bも
  for (int i = 1; i < N; i += 2) {
    int add = card.at(i);
    B += add;
  }
  cout << A - B  << endl;
}

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

int main(void)
{
	char str[20];
	int i;
	
	scanf("%s", str);
	
	for (i = strlen(str) - 1; i >= 0; i--){
        printf("%c", str[i]);
    }
    printf("\n");
    
    return (0);
}

Measured memory_bytes: 524
# editorialを参考にした。なお、ord("a")=97,ord("b")=98...となっていることを使っている
S = input()
T = input()
StoT = [-1] * 26  # 変換は1対1対応をとっていないといけない
TfromS = [-1]*26
ans = 1

for i in range(len(S)):
    num_s = ord(S[i]) - 97
    num_t = ord(T[i])-97
    if StoT[num_s] == -1:
        StoT[num_s] = num_t
    else:
        if StoT[num_s] != num_t:
            ans = 0
            break

    if TfromS[num_t] == -1:
        TfromS[num_t] = num_s
    else:
        if TfromS[num_t] != num_s:
            ans = 0
            break

if ans == 1:
    print("Yes")
else:
    print("No")


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

#define rep(i,n) for(int i = 0; i < n; i++)

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n)cin>>s.at(i);
  rep(j,26){
    int m = 100;
    rep(i,n)m = min(m,(int) count(s.at(i).begin(),s.at(i).end(),(char)('a'+j)));
    rep(i,m)cout<<(char)('a'+j);
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
S = gets.chomp.chars
T = gets.chomp.chars

s = S.length
t = T.length

(s-t).downto(0).each do |i|
  check = S[i..i+t-1].zip(T).all?{|a,b| a == b or a == "?"}
  if check
    retval = S.join.gsub("?", "a").chars
    retval[i..i+t-1] = T
    puts(retval.join)
    exit
  end
end

puts "UNRESTORABLE"

Measured memory_bytes: 1788
while True:
    n = int(input())
    if n==0:
        break
    t = input()
    
    for i in range(n):
        s = list(t)
        S = []
        for i in range(len(s)):
            S.append(int(s[i]))
        i = 1
        c = 0
        r = []
        a = [S[0]]
        while True:
            if S[i-1]==S[i]:
                c += 1
            else:
                r.append(c+1)
                a.append(S[i])
                c = 0
            i += 1
            if i==len(S):
                r.append(c+1)
                break
        
        S.clear()
        for j in range(len(r)):
            S.append(str(r[j]))
            S.append(str(a[j]))
        t = ''.join(S)
    
    print(t)


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

#define ll long long

using namespace std;


int main(){
	ll x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2-(y2-y1) << " " << y2 + (x2-x1) << " " 
		 << x1-(y2-y1) << " " << y1 + (x2-x1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N,D,X;
     cin >> N >> D >> X;
     vector<int> A(N);
     for(int i = 0; i < N; i++){
          cin >> A[i];
     }
     int cnt = X;
     for(int j = 0; j < N; j++){
          int d = 1;
          while(d <= D){
               d += A[j];
               cnt++;
          }
     }
     cout << cnt << endl;
}

Measured memory_bytes: 256
# AOJ ITP1_11_D

# サイコロ。

command = " SSESS"  # すべての面を総当たり。
check = []  # 側面チェック用。
check.append([2, 3, 5, 4])
check.append([3, 5, 4, 2])
check.append([5, 4, 2 ,3])
check.append([4, 2, 3, 5])

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

class dice:
    def __init__(self):
        self.data = [0 for i in range(8)]
        a = intinput()
        for i in range(1, 7): self.data[i] = a[i - 1]  # 1, 2, 3, 4, 5, 6.
        for i in range(6): self.data[0] += a[i]  # 各位の和を0に。
        self.data[7] = a[0] * a[5] + a[1] * a[4] + a[2] * a[3]  # 対面同士の積の和を7に。
        # dataの1, 2, 3, 4, 5, 6というindexが位置を示す。
        # 回転するとそれらの位置にある数が変化するイメージ。

    def d_read(self, a):
        # aはたとえば5, 1, 2, 6のような配列
        b = []
        for i in range(len(a)): b.append(self.data[a[i]])
        return b

    def d_write(self, b, c):
        # cはたとえば1, 2 ,6, 5のような配列で、そこにbの中身を落とす。
        if len(b) != len(c): return     # 要求と異なる。
        for i in range(len(b)): self.data[c[i]] = b[i]

    def roll(self, direction):
        # directionが'S', 'E', 'W', 'N'.
        # 'S', 'N'では3と4が不変。 'E'と'W'では2と5が不変。
        if direction == ' ': return
        if direction == 'S':
            self.d_write(self.d_read([5, 1, 2, 6]), [1, 2, 6, 5])
            
        elif direction == 'N':
            self.d_write(self.d_read([2, 6, 5, 1]), [1, 2, 6, 5])
            
        elif direction == 'W':
            self.d_write(self.d_read([3, 6, 4, 1]), [1, 3, 6, 4])
            
        elif direction == 'E':
            self.d_write(self.d_read([4, 1, 3, 6]), [1, 3, 6, 4])

    def get_label(self, i):  # i番の面の数を返す。
        return self.data[i]

    def get_index(self, n):  # nが書かれた面のindexを返す。
        for i in range(1, 7):
            if self.data[i] == n: return i
        return -1  # 見つからない場合。

def side_check(d1, d2):
    # 上面と下面が合ってる場合の側面チェック。
    for i in range(4):
        j = 2
        while j < 6:
            if d2.get_label(check[0][j - 2]) != d1.get_label(check[i][j - 2]): break
            j += 1
        if j == 6: return True
    return False

def is_equal(d1, d2):
    if d1.get_label(0) != d2.get_label(0): return False
    if d1.get_label(7) != d2.get_label(7): return False
    # SSESSの順にまわしていけばすべての面が上面に来る。
    for i in range(6):
        d2.roll(command[i])  # 最初だけ何もしない。
        if d2.get_label(1) != d1.get_label(1): continue
        if d2.get_label(6) != d2.get_label(6): continue
        if side_check(d1, d2): return True
    return False

def main():
    diceset = []
    n = int(input())
    for i in range(n):
        diceset.append(dice())
    distinct = True
    for i in range(n):
        for j in range(i + 1, n):
            if is_equal(diceset[i], diceset[j]):
                distinct = False; break
    if distinct: print("Yes")
    else: print("No")

if __name__ == "__main__":
    main()


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

int main(int argc, char const *argv[]) {
    string S;
    cin >> S;
    bool judge = false;


    if (S.at(0) == S.at(1)) {
        if (S.at(0) != S.at(2) && S.at(2) == S.at(3)) {
            judge = true;
        }
    } else if (S.at(0) == S.at(2)) {
        if (S.at(1) == S.at(3)) {
            judge = true;
        }
    } else if (S.at(0) == S.at(3)) {
        if (S.at(1) == S.at(2)) {
            judge = true;
        }
    }
    
    if (judge) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    string S;
    cin>>S;
    int Sz=S.size();
    vector<vector<ll>> dp(Sz+1, vector<ll>(2));
    dp[Sz][0]=0;
    dp[Sz][1]=INF;
    for(int i=Sz-1; i>=0; i--){
        dp[i][0]=INF;
        dp[i][1]=INF;
        int K=S.at(i)-'0';
        dp[i][0]=min(dp[i+1][0]+K, dp[i+1][1]+K+1);
        dp[i][1]=min(dp[i+1][0]+10-K, dp[i+1][1]+10-K-1);
    }
  	ll Ans=min(dp[0][0], dp[0][1]+1);
    cout<<Ans<<endl;
  	
}

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

using namespace std;

typedef long long  ll;

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

    int n;

    cin >> n;
    vector<int> f(n);
    for (int i = 0; i < n; ++i) {
        cin >> f[i];
        --f[i];
    }

    int num = 0;
    for (int i = 0; i < n; ++i) {
        if (i < f[i] && f[f[i]] == i)
            ++num;
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
*/
int n, k, mod = 1e9 + 7;
int dp[101][100001];
int arr[102];

int32_t main()
{
    ios;
    cin >> n >> k;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }

    for (int i = 1; i <= n; i++)
    {
        vector<int> pre(k + 1);
        pre[0] = dp[i - 1][0];
        for (int kk = 1; kk <= k; kk++)
        {
            pre[kk] = (pre[kk - 1] + dp[i - 1][kk]) % mod;
        }
        for (int curr = 0; curr <= k; curr++)
        {
            dp[i][curr] = (dp[i][curr] + pre[curr]) % mod;
            if (curr - min(curr, arr[i]) - 1 >= 0)
                dp[i][curr] = (dp[i][curr] - (pre[curr - min(curr, arr[i]) - 1]) % mod + mod) % mod;
        }
    }
    cout << dp[n][k] << endl;
}


Measured memory_bytes: 79220
while(1):
	
	a, op, b = map(str, input().split())
	if op == "+":
		print("%d" % (int(a)+int(b)))
	elif op == "-":
		print("%d" % (int(a)-int(b)))
	elif op == "/":
		print("%d" % (int(a)//int(b)))
	elif op == "*":
		print("%d" % (int(a)*int(b)))
	else:
		break

Measured memory_bytes: 7552
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  int A[N];
  for(int i=0; i<N; i++)
    cin >> A[i];
  int ret[H][W];
  int row_t = 0;
  int col_t = 0;
  for(int i=0; i<N; i++){
    int num = A[i];
    while(num > 0){
      ret[row_t][col_t] = i + 1;
      if(row_t % 2 == 0){
        if(col_t == W - 1)
          row_t++;
        else
          col_t++;
      } else {
        if(col_t == 0)
          row_t++;
        else
          col_t--;
      }
      num--;
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << ret[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}


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

#ifdef LOCAL
#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
#define bits(x) bitset<22>(x)
#define tham getchar()
#endif

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

mt19937_64 rng((unsigned)chrono::system_clock::now().time_since_epoch().count());
//const ll mod = ;
//const ld error = ;
const ld PI = acosl(-1);

//inline ll MOD(ll x, ll m = mod){
//    ll y = x % m;
//    return (y >= 0) ? y: y+m;
//}

//const int/ll inf = ;
const int nmax = 1e6+5;
///===========================================  template  =======================================================

int nodecnt = 1;
int nxt[nmax][26];
int cnt[nmax][26];
ll ans = 0;

int trie(int now, string &s, int index){
    int c = s[index]-'a';
    if(nxt[now][c] == 0){
        nxt[now][c] = ++nodecnt;
    }

    int mask = int(bt(c));
    if(index > 0){
        mask |= trie(nxt[now][c], s, index-1);
    }
    else{
        ans += cnt[now][c];
    }

    for(int d = 0; d<26; d++){
        if(mask&bt(d)) cnt[now][d]++;
    }
    return mask;
}

int main(){
    FASTIO;
    int n;
    cin>>n;
    vector<string> input(n);
    for(int i = 0; i<n; i++){
        cin>>input[i];
    }

    sort(input.begin(), input.end(), [&](string &s, string &t){return s.size() > t.size();});

    for(string &s : input){
        trie(1, s, int(s.size())-1);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 235424
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(int i=1;i<=k;i++)
    dp[0][i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        dp[i-1][j]=(0LL+dp[i-1][j]+dp[i-1][j-1]+mod)%mod;
        for(int j=0;j<=k;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j-arr[i-1]-1>=0)
            dp[i][j]=(0LL+dp[i][j]-dp[i-1][j-arr[i-1]-1]+mod)%mod;
        }
    }
    cout<<(0LL+dp[n][k]+mod)%mod<<"\n";
    return 0;
}

Measured memory_bytes: 39680
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

    long long n, k;
    cin >> n >> k;

    vector<long long> a(n), f(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<long long>());

    long long left = -1, right = 1e12;
    while (left + 1 < right) {
        long long mid = (left + right) / 2;

        long long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += max(0LL, a[i] - mid / f[i]);
        }

        if (sum <= k) right = mid;
        else left = mid;
    }

    /*
    for (int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
    for (int i = 0; i < n; i++) cout << f[i] << " ";
    cout << endl;
    */

    cout << right << endl;
    return 0;
}

Measured memory_bytes: 3328
# solution 2
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
L = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                L.append(A[i]+B[j]+C[k])
            else:
                break
L.sort(reverse=True)
for l in range(K):
    print(L[l])

Measured memory_bytes: 8708
n = int(input())


def improved_is_prime(n):
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    i = 3
    while i <= n**0.5:
        if n % i == 0:
            return False
        i += 2
    return True


cnt = 0

for _ in range(n):
    if improved_is_prime(int(input())):
        cnt += 1

print(cnt)



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

int main() {
  string s;
  int a, w, t, r;
  a = 0;
  w = 0;
  t = 0;
  r = 0;
  int n;
  cin >> n;
  while(n--) {
    cin >> s;
    if(s == "AC") a++;
    else if(s == "WA") w++;
    else if(s == "TLE") t++;
    else if(s == "RE") r++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define clr(a, x) memset(a, x, sizeof(a))
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define X first
#define Y second
#define fastin                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

int main()
{
#ifndef ONLINE_JUDGE
    // freopen("1.in", "r", stdin);
    // freopen("1.out", "w", stdout);
#endif
    fastin
    int n;
    cin >> n;
    vector<ll> a(n + 1), s(n + 1);
    map<ll, int> M;
    ll ans = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
    for (int i = 0; i <= n; i++) M[s[i]]++;
    for (auto& t : M) ans += 1LL * t.Y * (t.Y - 1) / 2;
    cout << ans << endl;
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	if (s == "SUN")cout << 7 << endl;
	else if (s == "MON")cout << 6 << endl;
	else if (s == "TUE")cout << 5 << endl;
	else if (s == "WED")cout << 4 << endl;
	else if (s == "THU")cout << 3 << endl;
	else if (s == "FRI")cout << 2 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 256
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1

    else:
        count=0
if c==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9168
#!/usr/bin/env python3

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

    n = 1
    s = 0

    for _ in a:
        if _ == n:
            n += 1
        else:
            s += 1
    if n == 1:
        print(-1)
    else:
        print(s)


main()

Measured memory_bytes: 26268
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int l,r;
  cin >> l >> r;
  int l2 = l% 2019;
  int r2 = r% 2019;
  if(r-l>=2018){
    cout << 0 << endl;
    return 0;
  }
  if(l2<r2){
    int ans = INF;
    for(int i = l2;i<r2;i++){
      for(int j = i+1;j<=r2;j++){
        ans = min(ans,i*j%2019);
      }
    }
    cout << ans << endl;
  }
  else if(l2 == r2){
    cout << l2*r2%2019 << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    int flag = 0;
    int C = 1;
    for (C; C<=3; C++) {
        if(A*B*C % 2 != 0) flag = 1;
    }
    if (flag == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

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

    cout << a/3 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    bool flag = false;
    for(int i=a; i<=b; i++)
    {
        if(i%k==0)
        {
            flag = true;
            break;
        }
    }
    if(flag)
    {
        cout<<"OK"<<'\n';
    }
    else
    {
        cout<<"NG"<<'\n';
    }
    
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


ll inv(ll a) {

	ll res = 1;
	int p = MOD - 2;
	while (p>0) {
		if (p & 1 == 1) { res *= a; res %= MOD; }
		a = a*a%MOD;
		p >>= 1;
	}
	return res;
}


int main()
{
	int K, N;
	cin >> N >> K;
	ll fact[5000];
	ll invfact[5000];
	fact[0] = 1;
	fyg(5000,1) {
		fact[y] = fact[y-1] * y;
		fact[y] %= MOD;
	}
	invfact[4999] = inv(fact[4999]);
	for (int y = 4998; y >= 0;y--) {
		invfact[y] = invfact[y + 1] * (y + 1);
		invfact[y] %= MOD;
	}
	fyg(K+1,1) {
		if (N - K < y - 1) {
			ce(0)
		}
		else {
			ll ans = fact[N - K + 1] * invfact[y];
			ans %= MOD;
			ans *= invfact[N-K-y+1];
			ans %= MOD;
			ans *= fact[K - 1];
			ans %= MOD;
			ans *= invfact[y - 1];
			ans %= MOD;
			ans *= invfact[K-y];

			ce(ans%MOD)
		}
	}
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main(){
    int H,W,N;cin>>H>>W>>N;
    int P=max(H,W);
    int ans=(N+P-1)/P;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
  int n,a,b;
  string s;
  cin>>s;
  bool f =false;
  rep(i,3)if(s[i]=='7')f=true;
  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

const int INF=1010101010;

int main()
{
    int n,Q;
    scanf(" %d %d", &n, &Q);

    vector<pi> s(n);
    rep(i,n)
    {
        int tmp;
        scanf(" %d", &tmp);
        s[i]=pi(tmp,i);
    }
    sort(all(s));

    vector<int> x(n);
    rep(i,n) x[i]=s[i].fi;

    vector<int> f(n);
    rep(i,n) f[s[i].se]=i;

    set<int> leader;
    while(Q--)
    {
        char q[10];
        int a;
        scanf(" %s %d", q, &a);

        if(q[0]=='A') leader.insert(f[a-1]);
        else if(q[0]=='R') leader.erase(f[a-1]);
        else
        {
            int ng=-1, ok=INF;
            while(ok-ng>1)
            {
                int mid=(ok+ng)/2;

                int ct=0,cr=-1;
                for(const int &idx:leader)
                {
                    int lidx=lower_bound(all(x),x[idx]-mid)-x.begin();
                    int ridx=upper_bound(all(x),x[idx])-x.begin()-1;

                    if(lidx<=cr) lidx=cr+1;
                    ct+=ridx-lidx+1;

                    cr=ridx;
                }

                if(n-ct<=a) ok=mid;
                else ng=mid;
            }

            if(ok==INF) printf("NA\n");
            else printf("%d\n", ok);
        }
    }

    return 0;
}

Measured memory_bytes: 18360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
// #define int long long
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

int32_t main()
{
    int n;
    cin >> n;
    int a, b, c;
    cin >> a >> b >> c;
    int dp[n][3];
    fill(dp, 0);
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for (int i = 1; i < n; i++)
    {
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][2], dp[i - 1][1]) + a;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c;
    }
    cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S;
  while (cin >> S) {
    vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for (int i = 0; i < days.size(); i++) {
      if (days[i] == S) {
        cout << (7 - i) << endl;
        break;
      }
    }
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct UnionFind {
  vector<int> par, s; 
  UnionFind(int N) : par(N), s(N) { rep(i,N) { par[i] = i; s[i] = 1; } }
  int root(int x) { return par[x]==x ? x : par[x] = root(par[x]); }
  int size(int x) { return par[x]==x ? s[x] : s[x] = size(root(x)); }
  void unite(int x, int y) { int rx=root(x), ry=root(y); if (rx!=ry) { s[rx] += s[ry]; par[ry] = rx; } }
  bool same(int x, int y) {  int rx=root(x), ry=root(y); return rx==ry; }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  int N, M, K; cin >> N >> M >> K;
  UnionFind uf(N);
  int adj[N] = {};
  rep(i,M) {
    int A, B; cin >> A >> B; A--; B--;
    uf.unite(A,B);
    adj[A]++; adj[B]++;
  }
  // rep(i,N) cout << uf.size(i) << " "; cout << endl;
  int block[N] = {};
  rep(i,K) {
    int C, D; cin >> C >> D; C--; D--;
    if (uf.same(C,D)) { block[C]++; block[D]++; }
  }

  int result[N] = {};
  rep(i,N) result[i] = uf.size(i) - (adj[i]+block[i]+1);
  debug(result,result+N);
  return 0;
}

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

int dfs(int node, vector<int> adj[], vector<bool> &visited) {
    int cnt=1;
    visited[node] = true;
    for(int i:adj[node]) {
        if(!visited[i]) {
            cnt += dfs(i, adj, visited);
        }
    }
    return cnt;
}

void code() {
    int n,m;
    cin>>n>>m;
    int ans=0  ;
    vector<int> adj[n];
    for(int i=0; i<m; i++) {
        int u,v;
        cin>>u>>v;
        u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    vector<bool> visited(n);
    for(int i=0; i<n; i++) {
        if(!visited[i])
            ans = max(ans, dfs(i, adj, visited));
    }
    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 27044
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char a[4];
	int b=0;
	cin>>a;
	if (a[0]=='2') b++;
	if (a[1]=='2') b++;
	if (a[2]=='2') b++;
	if (a[3]=='2') b++;
	cout<<b;
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <stack>
#include <iostream>
#define INT long long
using namespace std;

INT n, x, a[100001], ans;


int main()
{
    cin>>n>>x;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>a[i];
        if( a[i] > x ) ans += a[i]-x, a[i] = x;
    }
    for(int i = 0 ; i < n ; i++ )
    {
        if( a[i] + a[i+1] > x ) ans += ( a[i] + a[i+1] ) - x, a[i+1] -= ( a[i] + a[i+1] ) - x;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3568
#!/bin/env python
#｜sum(L)-sum(L-L[i])｜ が最少となるiの時のsum(L-L[i])を求める
def main():
  n,l = map(int,input().split())
  ans = (2*l+n-1)*n//2
  if l > 0:
    ans -= l
  elif l+n-1 <0:
    ans -= (l+n-1)
  print(ans)
main()


Measured memory_bytes: 38592
use proconio::input;

fn main() {
  input! {
    n: usize, k: usize,
    mut l: [u64; n],
  }
  
  l.sort();
  
  let mut len = 0;
  for i in n-k..n {
    len += l[i];
  }
  
  println!("{}", len);
}

Measured memory_bytes: 2128
#include<cstdio>
#define MN 500
char s[MN+5][MN+5],a[MN+5][MN+5],b[MN+5][MN+5];
int main()
{
	int n,m,i,j;
	scanf("%d%d",&n,&m);
	for(i=2;i<n;i+=2)for(j=2;j<m;++j)a[i][j]='#';
	for(i=3;i<n-1;i+=2)if((i/2)&1)a[i][2]='#';else a[i][m-1]='#';
	for(i=1;i<=n;++i)for(j=1;j<=m;++j)
		if(a[i][j]=='#')b[i][j]='.';
		else a[i][j]='.',b[i][j]='#';
	for(i=1;i<=n;++i)
	{
		scanf("%s",s[i]+1);
		for(j=1;j<=m;++j)if(s[i][j]=='#')a[i][j]=b[i][j]='#';
	}
	for(i=1;i<=n;++i)puts(a[i]+1);
	for(i=1;i<=n;++i)puts(b[i]+1);
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <string>

int main()
{
  int a,b,c;
	std::cin >> a >> b >> c; std::cin.ignore();

	std::cout << (((a == b && b == c) || (a != b && b != c && a != c)) ?  "No" : "Yes") << std::endl;
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
//作者：中国江苏南京朱泽齐
int a;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>a;
	if(a<1200)
	cout<<"ABC"<<endl;
	else
	cout<<"ARC"<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])

ans = 0
bus = []

for i in range(n):
    if len(bus) == c:
        ans += 1
        bus = [t[i]]
    elif bus != [] and bus[0] + k < t[i]:
        ans += 1
        bus = [t[i]]
    else:
        bus.append(t[i])

print(ans+1)

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


int main() {
    int n, m, q;
    cin >> n >> m >> q;

    vi a(q), b(q), c(q), d(q);
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    ll ans = 0;
    vi A(n, 1);
    while (true) {
        ll sum = 0;
        rep(i, q) {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i])
                sum += d[i];
        }
        umax(ans, sum);

        rrep(i, n) {
            if (A[i] < m) {
                A[i]++;
                int t = A[i];
                rep(j, i + 1, n)
                    A[j] = t;
                break;
            }
            if (i == 0) {
                cout << ans << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random> 
#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 3000;
string s, t;
int dp[MAX_N+1][MAX_N+1];
string strDp[2][MAX_N+1];

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

  cin >> s >> t;

  string *pre = strDp[0];
  string *nxt = strDp[1];
  for (int i = 1; i <= len(s); ++i) {
      for (int j = 1; j <= len(t); ++j) {
          if (s[i-1] == t[j-1]) {
              dp[i][j] = dp[i-1][j-1] + 1;
              nxt[j] = pre[j-1] + s[i-1];
          } else {
              if (dp[i-1][j] > dp[i][j-1]) {
                  dp[i][j] = dp[i-1][j];
                  nxt[j] = pre[j];
              } else {
                  dp[i][j] = dp[i][j-1];
                  nxt[j] = nxt[j-1];
              }
          }
      }
      swap(pre, nxt);
  }

  cout << pre[len(t)] << endl;

  return 0;
}


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

int main()
{
    std::vector<int> x(3);
    std::cin >> x[0] >> x[1] >> x[2];
    std::sort(x.begin(), x.end());
    std::cout << x[0] << " " << x[1] << " " << x[2] << std::endl;

    return 0;
}


Measured memory_bytes: 3116
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>


int *array1,*array2;
int n,q;
bool solve(int i,int m){
    bool res;
    if(m==0)
        return true;
    if(i>=n)
        return false;
    res=solve(i+1,m)||solve(i+1,m-array1[i])?true:false;
    return res;
}

int main(){

    scanf("%d",&n);
    array1=malloc(sizeof(int)*n);
    for(int i=0;i<n;i++){
        scanf("%d",&array1[i]);
    }
    scanf("%d",&q);
    array2=malloc(sizeof(int)*q);
    for(int j=0;j<q;j++){
        scanf("%d",&array2[j]);
    }

    for(int k=0;k<q;k++){
        printf("%s\n",solve(0,array2[k])?"yes":"no");
    }

    return 0;

}



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

int main() {
  int n,x;
  cin >> n;
  int f=0;
  x = n;
  
  for(int i = 0; i < 9 ; i++){
    f +=n%10;
    n /=10;
  }
  
  if(x%f==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            long[] x = new long[N], y = new long[N], z = new long[N], sum = new long[N];
            for (var i = 0; i < N; ++i)
            {
                var xyz = Sarray();
                x[i] = xyz[0];
                y[i] = xyz[1];
                z[i] = xyz[2];
            }
            var ans = 0L;
            for (var i = -1; i < 2; i += 2)
                for (var j = -1; j < 2; j += 2)
                    for (var k = -1; k < 2; k += 2)
                    {
                        for (var l = 0; l < N; ++l)
                            sum[l] = i * x[l] + j * y[l] + k * z[l];
                        Array.Sort(sum);
                        ans = Max(ans, sum.Skip((int)(N - M)).Take((int)M).Sum());
                    }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28728
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
typedef long long ll;
using namespace std;

int main() {
  int N; cin>>N;
  vector<int> A(N); REP(i,N) {cin>>A.at(i); A.at(i) = A.at(i)-(i+1);}
  int med; //median
  ll ans=0;

  SORT(A);
  med = A.at(N/2);
  REP(i,N) ans += abs(A.at(i) - med);

  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007
typedef long long ll;

int
main(int argc, char *argv[])
{
  int r;
  scanf("%d", &r);
  printf("%d\n", 3 * r * r);
  return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;


public class  Main{
    public static void main(String[] args) throws Exception{
    	MScanner sc = new MScanner(System.in);
        //MScanner sc = new MScanner("reduce.in");
        PrintWriter pw=new PrintWriter(System.out);
        //int n=sc.nextInt();
        //Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=sc.nextInt();
        String x=sc.nextLine();
        HashMap<Character,Integer>occ=new HashMap<Character, Integer>();
        for(int i=0;i<4;i++) {
        	occ.put(x.charAt(i),occ.getOrDefault(x.charAt(i),0)+1);
        }
        for(Entry<Character,Integer>e:occ.entrySet()) {
        	if(e.getValue()!=2) {
        		pw.println("No");pw.flush();return;
        	}
        }
        pw.println("Yes");
        pw.flush();
    }
    static StringBuilder tosb(int[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    static StringBuilder tosb(long[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    rep(i,s.size()){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cnt++;
        }else cnt=0;
        ans = max(cnt,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568