akhauriyash/Code-Regression huggingface dataset:
from collections import deque
S=input()
s=deque(S)
Q=int(input())
Que=[list(map(str, input().split())) for _ in range(Q)]
#print(Que)
a=0
for i in range(Q):
    if Que[i][0]=="1":
        a+=1
    elif Que[i][0]=="2":
        if a%2==0:
            if Que[i][1]=="2":
                s.append(Que[i][2])
            elif Que[i][1]=="1":
                s.appendleft(Que[i][2])
        else:
            if Que[i][1]=="1":
                s.append(Que[i][2])
            elif Que[i][1]=="2":
                s.appendleft(Que[i][2])
s=list(s)
if a%2==1:
    s=s[::-1]
ans="".join(s)
print(ans)


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

vector <ll> adj[100001];
ll dp[100001];
bool visited[100001];

void dfs(ll src)
{
	visited[src]=true;
	for(auto a:adj[src])
	{
		if(visited[a]==false)
		{
			dfs(a);
		}
		dp[src] = max(dp[src],1+dp[a]);
	}
}

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

    ll n,m,i;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
    	ll u,v;
    	cin>>u>>v;
    	adj[u].push_back(v);
    }
    
    memset(dp,0,sizeof(dp));
    memset(visited,false,sizeof(visited));

    for(i=1;i<=n;i++)
    {
    	if(visited[i]==false)
    		dfs(i);
    }
    ll res = 0;
    for(i=1;i<=n;i++)
    {
    	res = max(res,dp[i]);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n,W;
    cin >> n >> W;
    vector<ll> weight(n,0);
    vector<ll> value(n,0);
    rep(i,n)cin >> weight[i] >> value[i];
    vector<vector<ll>> dp(n+5,vector<ll>(W+5,0));

    for(ll i = 0;i < n; i++){
        for(ll w = 0; w <= W;w++){
            if(w >= weight[i])dp[i+1][w] = max(dp[i][w] , dp[i][w - weight[i]] + value[i]);
            else dp[i+1][w] = dp[i][w];
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n,p;
    cin >>n;
    vector<int> v;
    p=n;
    while (p--){
        int x;
        cin >> x;
        v.push_back(x);
    }
    reverse(v.begin(), v.end());
    for (int i = 0; i < n-1; i++){
        cout << v[i] << ' ';
    }
    cout << v[n-1] << "\n";
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define mod 998244353
#define MAXC 3001
#define MAXD 3001
ll dp[MAXC][MAXD];
int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    memset(dp, 0, sizeof(dp));
    dp[a][b] = 1;
    for (int i = a; i <= c; i++) {
        for (int j = b; j <= d; j++) {
            if ((i == a)&&(j == b)) continue;
            dp[i][j] = (dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1)) % mod;
            // cout << "i " << i << " j " << j << " " << dp[i][j] << endl;
        }
    }
    cout << (dp[c][d] + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 73952
import math

n, m = [int(i) for i in input().split()]
ret = []

i = 1
while i * i <= m:
    if m % i == 0:
        ret.append(i)
        ret.append(int(m / i))
    i += 1
#ret.append(m)
ret = sorted(ret)
#print(ret)
for i in reversed(ret):
    if i <= int(m/n):
        print(i)
        exit()


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

int main() {
 
  int a, b, k;
  cin >> a >> b >> k;
  
  vector<int> c(100);
  int j = 0;
  REP(i,100) {
    if (a % (i+1) == 0 && b % (i+1) == 0) {
      c[j] = i+1;
      j++;
    }
  }
  
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  
  cout << c[k-1] << endl;
 
}

Measured memory_bytes: 3632
from collections import Counter

def max_rectangle(sticks):
    # sticks ordered by length, only if there's at least two of a kind
    valid_lengths = list(filter(lambda x: sticks[x] >= 2, sorted(sticks, reverse=True)))
    if valid_lengths and sticks[valid_lengths[0]] >= 4:
        return valid_lengths[0] ** 2
    if len(valid_lengths) >= 2:
        return valid_lengths[0] * valid_lengths[1]
    return 0


if __name__ == '__main__':
    _ = input()
    sticks = Counter(map(int, input().split()))
    print(max_rectangle(sticks))


Measured memory_bytes: 24104
#include<stdio.h>

int main()
{
	int x[100]={0},y[100]={0},z,n,t=0,r=0;
	while(scanf("%d",&n) !=EOF)
	{
		if(n>=1)
		{
			x[t]=n;
			t++;
		}
		else if(n==0)
		{
			t--;
			y[r]=x[t];
			r++;
		}
	}
	
	for(z=0;z<r;z++)
	{
		printf("%d\n",y[z]);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
 
int main(void) {
  char T[200000];
  if(scanf("%s", T)==1);
  int i, frag;
  for (i=0; i<200000; i++) {
    if (T[i]=='?') {
      T[i]='D';
    }
    else if(T[i]==NULL) {
      break;
    }
  }
  printf("%s", T);
  return 0;
}


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


int main(){
    int N, M;
    cin >> N >> M;
    vector< vector<int> > data(N);

    for (int i = 0; i < M; ++i){
        int A, B;
        cin >> A >> B;
        data[A - 1].push_back(B - 1);
        data[B - 1].push_back(A - 1);
    }

    int flag[N];
    for (int i = 0; i < N; ++i){
        flag[i] = 0;
    }

    int ans = 1;
    for (int i = 0; i < N; ++i){
        if (flag[i] == 1){
            //何もしない
        } else{

            flag[i] = 1;
            int count = 0;

            vector<int> que;
            que.push_back(i);

            while(que.size() != 0){
                count += 1;

                int u = que.back();
                que.pop_back();

                for (int j = 0; j < data[u].size(); ++j){
                    int v = data[u][j];
                    if (flag[v] == 1){
                        //何もしない
                    } else{
                        flag[v] = 1;
                        que.push_back(v);
                    }
                }  
            }
            ans = max(ans, count);
        }
    }
    cout << ans << endl;
}

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

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

    int hi = max(h, w);
    int ans = 0;
    int i = 0;
    do {
        i++;
        ans += hi;

    } while(ans < n);
    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256